How do I install a global npm package to a node-module folder in my project

like the question says. I was trying to use npm link <package> but it installs in usr/local or something like that

btw im using linux

Within the actual package that you’re trying to link (eg a node module you are developing), run npm link

That will create a symlink to it in the global package folder (I’m assuming that’s the one you reference: it’s helpful if you could be a bit more specific there – “something like that” is not helpful, particularly given that you can see exactly what the path it is).

Then in the project you want to use the linked package, run npm link whatever-the-package-is-called, and npm will create another symlink from the global folder to the project’s node_modules

Edit: just so that this isn’t abstract:

  1. You are developing a Node module
  2. You want to test that module in the context of another node application as you develop it.
  3. You don’t want to have to build the package and then reinstall it in the app every time something changes.
  4. You use link to allow a direct link between the package you are developing and the application you’re testing it in.
  5. Linking is two-stage: first generate a symlink from the package to the global node modules folder.
  6. Then generate symlinks from the global folder to whichever projects want to use the under-development package.