9

When I install modules with NPM on Windows, it installs them to:

~/node_modules

I'd like to set change this to an arbitrary path such as:

c:\dev\repo\node_modules

I've tried

npm config set prefix <path>

With various values but none of them seem to work.

Jonas
  • 121,568
  • 97
  • 310
  • 388
cliff.meyers
  • 17,666
  • 5
  • 51
  • 66
  • 4
    npm used to be able to do this. But the maintainers of npm have decided to move forward with the philosophy that each project should have its own modules directory to avoid version conflicts. There is still the global `-g` install for OS-wide stuff like command line tools such as grunt and mocha. You still have a limited ability to store modules in an almost arbitrary path due to how `require` searches for module. It first searches in `./node_modules` then `../node_modules` then `../../node_modules` etc. – slebetman Nov 02 '13 at 14:57
  • 1
    This answer worked for me: http://stackoverflow.com/a/18264557/1696030 "npmrc file can be found in C:\path\to\nodejs\node_modules\npm\npmrc" – Volker E. May 01 '14 at 22:08

1 Answers1

4

As mentioned in the FAQ npm installs modules locally, to avoid dependency conflicts with nesting dependencies. If you really want different projects to reference the same copy you can use npm link.

mtsr
  • 3,092
  • 1
  • 14
  • 21