Question

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
node-dev@2.0.2 /usr/local/share/npm/lib/node_modules/node-dev
├── growl@1.7.0
├── dateformat@1.0.6-1.2.3
└── chokidar@0.6.2

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

Was it helpful?

Solution 2

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.

OTHER TIPS

In your '._bash_profile' (If it doesn't exist, create it in your $HOME)

export PATH="$HOME/.npm-packages/bin:$PATH"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top