karma command not found when karma already installed

前端 未结 9 1837
独厮守ぢ
独厮守ぢ 2021-01-30 19:49

I used node.js to install karma. My first try failed when running the following command on Terminal:

npm install -g karma

That failed so I dec

相关标签:
9条回答
  • 2021-01-30 20:08

    In your ~/.bash_profile (or similar) amend your PATH to include npm-installed binaries:

    export PATH="$PATH:/usr/local/share/npm/bin"
    

    I had this very same issue, and found this solution to be less time-consuming and impactful than completely re-installing node.

    EDIT this has also worked for others in bash_profile

    export PATH="$PATH:/usr/local/lib/node_modules/karma/bin" 
    
    0 讨论(0)
  • 2021-01-30 20:11

    I had to add export PATH="$PATH":/usr/local/lib/node_modules/npm/node_modules/karma/bin after installing karma with sudo npm install karma.

    hope this helps.

    0 讨论(0)
  • 2021-01-30 20:18

    When upgrading from Karma 0.10 to 0.12 the link to the karma executable is removed.

    You can get it back with

    cd node_modules/.bin
    ln -s ../karma/bin/karma karma
    
    0 讨论(0)
  • 2021-01-30 20:20

    Just go to test.sh:

    Find: $BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma.conf.js $*

    Replace with: /usr/local/bin/karma start $BASE_DIR/../config/karma.conf.js $*

    Or: karma start $BASE_DIR/../config/karma.conf.js $*

    0 讨论(0)
  • 2021-01-30 20:22

    It is recommended to install karma with its Command-Line-Interface (karma-cli) which will take care of fetching the appropriate karma. You can also install a different local version specific to each project you're working on and karma-cli will pick the appropriate one.

    From the karma installation page:

    Typing ./node_modules/karma/bin/karma start sucks so you might find it useful to install karma-cli globally:

    npm install -g karma-cli
    

    Now, check that karma was installed by typing:

    karma start
    

    You can also check that karma was installed by going to this directory:

    cd /usr/local/lib/node_modules/karma
    

    Good luck!

    0 讨论(0)
  • 2021-01-30 20:28

    Don't need to completely uninstall node.js

    Just

    sudo rm -rf /usr/local/lib/node_modules/npm/
    

    Then
    install node.js

    Then
    reinstall karma

    This worked for me.

    0 讨论(0)
提交回复
热议问题