npm install -g xyz
installs the module xyz gets to what I would call a 'global modules directory' i.e. C:\Users\me\AppData\Roaming\npm\node_modules
in Windows 7.
However, there seems to be no way to make all my node projects use these modules.
If I have a project in C:\temp\test.js
then require('xyz')
cannot find the module.
NODE_PATH
to the above global modules directory doesn't helpnpm link
only works with published modules not my own unpublished onesShort of putting all my projects in a sub-folder of the global modules directory (so that node traverses up and finds node_modules/) is there any way of re-using those global modules?
If so, what is the point of -g and 'global' modules?
Global modules are only used for command line tools. For example if you install Express.js globally you can use express --session
to create new projects. If you need to require express in your project then you need to install it in the local node_modules directory.