No, this is absolutely not the way to go, definitely :)
How it works:
* when looking for a module, node will search in "node_modules" folder (and will look for it in parent folder, going up until it finds a "node_modules" folder).
* when you "
npm install module" it will install the module in current folder's "node_modules" (it will try to find an existing one, or will search in parent folders etc... or create it).
Therefore,
"npm install" and "require" work hand by hand, happily together.
It has also many more advantages, like making you able to use different versions of libraries in your different projects.
How it doesn't work:
* when you "npm install -g module", the module is installed somewhere in a system folder.
* when you will "require(module)" it will not find it, unless you tell node what this system folder is.
It also has many more disadvantages, like... you know :)
Easy way: "npm install module"
Sucky way: "npm install -g module"
Why the fuck people do global installs ? For the binaries! Even expressjs recommands a global install so you can call "express" binary. That's a baaaaad advice!
Simply do this:
add "./node_modules/.bin" to your $PATH.
Then you can "npm install express" and... tadaaaa! call directly "express" (which will be found in ./node_modules/.bin/express, as locally installed) which will work without requiring any global install.
Honestly, I can't find any good reason to make global install. Oh yes, you can save some disk-space ? redis+contracts+ejs+express+tab+vows = 4M. You *can* duplicate this, even on your little SSD :)
si ce message est crypté:
- PGP KeyID -> 0x2F080247
- ou
http://naholyr.free.fr/naholyr.pubring.gpg