this is a very newbie question. But I really cannot figure it out through Google search. I want to understand what happens when one executes
sudo npm install -g "node module name"
I understand that the right module will be installed to, normally, /usr/local/.... However, why would this be available globally?
For example, I installed node-inspector locally in my project. But my shell does not understand when I type "node-inspector".
But once I install it globally,
node-inspector &
command will does the right thing for me. I really want to understand how this happens.
Thanks
Quoting the npm's doc:
- Local install (default): puts stuff in
./node_modules
of the current package root.- Global install (with
-g
): puts stuff in/usr/local
or wherever node is installed.- Install it locally if you're going to
require()
it.- Install it globally if you're going to run it on the command line.
- If you need both, then install it in both places, or use
npm link
.
It's quite a short description (which, I suppose, is still enough to see the difference), but the linked page describes the whole process of installing modules with npm
in more details. )