At startup
npm update
It will update dependencies to obey package.json , and does not care about what is stored in npm-shrinkwrap.json
, even if the node_modules
folder node_modules
empty, which means the update command will be installed using package.json
while the install command will use npm-shrinkwrap.json
.
It makes no sense to obey the shrinkwrap file [in most cases.]
Cause
This is supposed to be a snapshot of the package at some stable point, and this thing makes it ideal for production code.
The shrinkwrap file does not have ^
, ~
, latest
, etc.
- And we also know that the shrinkwrap file should not be cracked manually using the editor
- So all we can do is revert to the previous dependency state using this command, and this thing can be achieved with npm install
However, at startup
npm install
It follows the shrinkwrap file.
But when you run
npm install newPkg
It will also modify package.json
and npm-shrinkwrap.json
But when you run
npm update pkg
It will only change the npm-shrinkwrap.json
and, as I wrote, before it will use the package.json
file to update according to semver
source share