Harsan Harsan - 27 days ago 10
Node.js Question

How to set the default path for node modules?

I have installed node.js at my local system (path : C:\Program Files\nodejs). I installed some modules and expected them to be placed in (C:\Program Files\nodejs\node_modules). But, the installed modules are placed at C:\Users\Administrator\AppData\Roaming\npm\node_modules. Is this right or wrong? Can i access these modules globally?

My system platform is windows 7, and my version of node is 0.10.

Ari Ari
Answer Source

Running just npm install will install all modules into a folder in the current directory called node_modules; all files within the same root directory (even in sibling folders), will check for modules here when you call require. You should install any modules that you wish to require in your project this way.

If you want to install a module from npm globally, you can append the -g flag. This is usually for command-line tools, which you want to be accessible across multiple projects. An example would be npm install nodemon -g

If you are still confused, I recommend you reference this blog post from the makers of node on global/local installation: http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/