Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to interrupt a running `npm install` with ^C?

Tags:

node.js

npm

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?

like image 780
mik01aj Avatar asked Dec 07 '15 13:12

mik01aj


People also ask

How do you stop a run in npm?

To stop a running npm process, press CTRL + C or close the shell window.

What happens if you npm install without -- save?

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.

What does npm C do?

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.

Is everything on npm safe?

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.


2 Answers

Answer from @zkat on github:

As of npm@3, anything that modifies your node_modules folder (such as npm install) will automatically repair your node_modules/ folder -- so, if you break things with ^C, just rerun npm install and you're good to go!

like image 73
mik01aj Avatar answered Oct 13 '22 10:10

mik01aj


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.

like image 38
Nick Kenens Avatar answered Oct 13 '22 09:10

Nick Kenens