pulkitsinghal
pulkitsinghal

Reputation: 4084

How to instruct `npm` to not download existing packages?

Although it should be the responsibility of npm cli tool itself but since the logs indicate that it contacts the npm registry even for packages that are already present ... my question becomes:

How do we avoid contacting npm registry for any packages that are already present in node_modules folder?

While I understand that it is part of the npm algorithm to create a complete clone by downloading all dependencies and then comparing them with the existing ones, it is way too inefficient for CI builds and I'm seeking advice or pointers to scritps that handle this better.

Upvotes: 0

Views: 49

Answers (1)

Zoltan Kochan
Zoltan Kochan

Reputation: 7646

Use the prefer-offline or offline config of npm.

The second one (offline) will make installation fail if any new package will have to be downloaded from the registry. So if the package will not be found in the local cache.

Upvotes: 1

Related Questions