Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

karma command not found when karma already installed

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 decided to use:

sudo npm install -g karma 

After entering my password it seemed to install correctly. I am pasting part of the output of the install, maybe it will mean something to someone and it will be relevant to my question. After all the npm http messages this is what I see:

> [email protected] install /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws > (node-gyp rebuild 2> builderror.log) || (exit 0)    CXX(target) Release/obj.target/bufferutil/src/bufferutil.o   SOLINK_MODULE(target) Release/bufferutil.node   SOLINK_MODULE(target) Release/bufferutil.node: Finished   CXX(target) Release/obj.target/validation/src/validation.o   SOLINK_MODULE(target) Release/validation.node   SOLINK_MODULE(target) Release/validation.node: Finished /usr/local/share/npm/bin/karma -> /usr/local/share/npm/lib/node_modules/karma/bin/karma [email protected] /usr/local/share/npm/lib/node_modules/karma ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ([email protected]) ├── [email protected] ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected]) ├── [email protected] ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) └── [email protected] ([email protected], [email protected], [email protected], [email protected]) 

Then when I try to run the following command to create a karma config file with this command:

karma init karma.config.js 

this is the message that gets returned:

-bash: karma: command not found 

I have tried the same command with sudo before it but I get the same result.

Does anyone have any idea as to what is going on? Any help is appreciated.

*Update! I decided to check a file named: builderror.log located in: /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws

This is what it shows:

gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/eperez/.node-gyp/0.10.5" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/.node-gyp" gyp http GET http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz gyp http 200 http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz 
like image 652
iChido Avatar asked Jul 17 '13 15:07

iChido


People also ask

How do I know if I have karma installed?

By installing Karma globally, you'll have access to the “karma” command no matter your current location. To verify whether the installation was successful, just run “karma –version” and you should see the current version number. You're also going to need specific plugins, depending on the other testing tools you use.

Which of the following command is used to grab the Karma-CLI?

Typing ./node_modules/karma/bin/karma start sucks and so you might find it useful to install karma-cli globally. You will need to do this if you want to run Karma on Windows from the command line. Then, you can run Karma simply by karma from anywhere and it will always run the local version.


2 Answers

@mayankcpdixit gave the answer up there in a response to the OP's original question, but I'll put it here again in case anyone misses it.

You do not need to uninstall everything, and if I had to manually add a new path link for every npm package I try to install I'd probably shoot myself.

npm install -g karma-cli 

Boom. Now you have karma command lines installed. Just like Grunt.


Edit: Please don't forget to upvote @mayankcpdixit as well, he commented directly on the original post, but didn't actually "answer" the question.

like image 132
Kirkland Avatar answered Sep 23 '22 20:09

Kirkland


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"  
like image 43
Marty Cortez Avatar answered Sep 24 '22 20:09

Marty Cortez