I'm trying to set up a development environment with several packages, and as a result I need to manually install some dependencies. More specifically, I have some local changes in several packages which I need to test before I can push them to github, so I can't just npm install
the top level because it won't pick up those change. So I run the first npm install
manually on packages which are missing, and then try to run my node code and see which package it is still missing, then try to npm install
what it says is missing.
However, when I go to install the second package, it ends up with this message:
added 3 packages from 4 contributors, removed 799 packages and audited 3 packages in 4.197s
The second install removed practically every package that was already installed! I didn't notice this until about the third time, when I realized that I seemed to be installing the same thing over and over.
However can I prevent this particularly naughty behavior and force npm to only install what I tell it to and leave everything else alone?
Have a look at npm link
if you need to test against modified packages.
From npm link: This is handy for installing your own stuff, so that you can work on it and test it iteratively without having to continually rebuild.
Say b
is a dependency of a
. You made changes to b
and want to check if a
still works with those changes. Instead of using b
in node_modules
installed from npm
, use your local, modified version:
cd ~/projects/b # go into the package directory
npm link # creates global link
cd ~/projects/a # go into some other package directory.
npm link b # link-install the package
Now, any changes to ~/projects/b
will be reflected in ~/projects/a/node_modules/b/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With