A few days ago, after upgrading the node. JS v8.0, the self-brought NPM also upgraded to 5.0, the first time the use of the time is really amazing: the original re-installed module to more than 10 seconds to things, now more than a second to take care of. Don't get excited, now I'm going to talk about some big changes in NPM 5:
- When using the
npm install xxx
command to install the module, the option is no longer required --save
and the module dependency information is automatically saved to the Package.json file;
- Installing the module action (changing the contents of the Node_modules folder) generates or updates the Package-lock.json file
- The published module will not contain the Package-lock.json file
- If you manually modify the version of a module that is already in the Package.json file, direct execution
npm install
does not install the newly specified version, only by npm install [email protected]
updating
Reinstalling the module is fast because the Package-lock.json file has been recorded in the entire Node_modules folder tree structure, even the module is recorded, and then re-install only need to download files directly (so it seems that Facebook's Yarn doesn't seem to have much advantage.)
With speed, npm dug a big hole:
in the future, directly change the version number of the corresponding module Package.json file, and then execute npm install
will not be updated (scary), you can only manually npm install [email protected]
install with the specified version number, and it will automatically update the Package-lock.json file. When executed directly npm install
, if the Package-lock.json file does not exist, it is created according to the Node_modules directory structure after the module is installed, and if the Package-lock.json file already exists, it will only be based on the The Package-lock.json file specifies the structure to download the module and does not ignore the Package.json file.
Article:Understanding Lock Files in NPM 5 Link: http://jpospisil.com/2017/06/02/understanding-lock-files-in-npm-5.html
Here is the NPM documentation for instructions on package-locks Link: https://docs.npmjs.com/files/package-locks
NPM5 Packag-lock.json