By "safe" I mean "easily fixable by running npm install
again". I suspect I sometimes have broken installations because I interrupt the process, but have no evidence to confirm that this is the cause.
And, if it is not safe, should I always rm -rf node_modules/
after interrupting npm?
To stop a running npm process, press CTRL + C or close the shell window.
Optional dependencies are those packages which are only used when a particular feature of the application is used and will not be required if that functionality isn't used. –no-save: When this command is used with npm install it will not allow the installed packages from being saved into the dependency section.
npm ci (also known as Clean Install) is meant to be used in automated environments — such as test platforms, continuous integration, and deployment — or, any situation where you want to make sure you're doing a clean install of your dependencies. It installs dependencies directly from package-lock.
The company claims it found more than 1,300 malicious npm packages in 2021 in npm. That's bad, but 1,300 out of 1.8-million is only 0.007222%. If you were to just randomly grab JavaScript packages for your program, odds are you'll be safe.
Answer from @zkat on github:
As of npm@3, anything that modifies your
node_modules
folder (such asnpm install
) will automatically repair yournode_modules/
folder -- so, if you break things with^C
, just rerunnpm install
and you're good to go!
It's fine to ^C
just be sure to do these 2 things after canceling the process.
rm -rf node_modules/
as you stated, as this will delete all of the existing installs, this prevents a lot of errors.
npm cache clean
just to be certain. This cleans the cache and allows you to do a npm install
on a clean slate.
This is a process that you're going to have to do quite a lot, since a lot of weird npm errors will pop up.
Although, there are almost no install errors that these 2 commands can't fix.
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