I'm new to node.js, and still in the process to setup its environment.
I installed node.js v0.8.14 and npm v1.1.65. I tried to install several modules to the project I'm working on. They worked fine.
Then, I installed some global modules, like node-dev and node-inspector. There is no error as far as I can see. I got result like:
/usr/local/share/npm/bin/node-dev -> /usr/local/share/npm/lib/node_modules/node-dev/bin/node-dev
[email protected] /usr/local/share/npm/lib/node_modules/node-dev
├── [email protected]
├── [email protected]
└── [email protected]
However, when I try to use it. It just said:
-bash: node-dev: command not found
I reinstalled it. Nothing changed. I added /usr/local/share/npm/bin/ to .bashrc based on some answers on similar problems. It still doesn't work.
Finally, I even tried to navigate to /usr/local/share/npm/bin/ and call node-dev directly. Same error. Though, if I double click node-dev file in Finder. It will show some results:
localhost:~ Xiao$ /usr/local/share/npm/lib/node_modules/node-dev/bin/node-dev ; exit;
Usage: node-dev [options] script [arguments]
I'm totally baffle. Does anyone have some idea about what's going on here?
Btw, I'm using Mac OSX 10.8.4.
EDIT: I found out that these globally installed scripts will work if I use full path. For example, /usr/local/share/npm/bin/node-dev works, but node-dev doesn't. Even I try to executed it under /usr/local/share/npm/bin
In your '._bash_profile' (If it doesn't exist, create it in your $HOME)
export PATH="$HOME/.npm-packages/bin:$PATH"
Apparently, I made a mistake to add bin path in .bashrc. It should be .bash_profile in Mac OS. After adding the /usr/local/share/npm/bin/ in $PATH, everything works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With