npm install -g karma does not install executable

1.1k views Asked by At

I have what looks like successful karma installation, yet karma is not in /usr/local/bin/ and is not found by bash.

Any idea what is wrong and how to fix it?

Here are the end installation messages:

> [email protected] install /usr/local/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
[email protected] /usr/local/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] ([email protected], [email protected], [email protected], [email protected])

2

There are 2 answers

0
spawnedc On BEST ANSWER

You can link it by yourself. As in:

#Assuming that /usr/local/bin is in your PATH
cd /usr/local/bin
ln -s /usr/local/lib/node_modules/karma/bin/karma

Clearly, this is not an ideal solution. I think there's a problem in the package.json of karma which prevents npm to create a link to the executable. Might be related to this.

0
gTcV On

It seems that npm places all installed binaries in the folder <npm-global-prefix>/bin, so to make these binaries available in the shell you can add the following line to your shell startup script (e.g. ~/.profile, ~/.bash_profile, ~/.bash_aliases):

export PATH=`npm prefix -g`/bin:$PATH