bier hier
bier hier

Reputation: 22580

Before npm install delete node_modules?

Is it necessary to delete node_modules before executing an 'npm install' for a more reliable installation or does npm overwrite everything?

Upvotes: 5

Views: 4833

Answers (1)

KJ3
KJ3

Reputation: 5298

Npm definitely does not overwrite everything every time. It runs through a fairly complicated process that I won’t dive deep into here, but in general you should not need to delete node_modules every time. npm exists to handle this situation and generally will only download newly added or updated packages.

I will occasionally find myself in the need to completely remove the node_modules directory in the event that I have been add/removing/updating a large number of packages. Sometimes packages can get cached. But it’s not a common occurrence and I usually only recommend it when you notice a package appears out of date.

Upvotes: 7

Related Questions