nodejs项目的package-lock.json文件的用途
在npm官網(wǎng)上有介紹:https://docs.npmjs.com/files/package-lock.json
package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
當(dāng)npm命令會(huì)修改node_modules樹形結(jié)構(gòu)或者package.json時(shí),package-lock.json文件會(huì)自動(dòng)被創(chuàng)建。
作用有三:
(1) Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies. 其他部署和CI/CD基于此可以安裝完全一致的依賴模塊。
(2) Provide a facility for users to “time-travel” to previous states of node_modules without having to commit the directory itself.
作為npm操作的版本記錄文件,能回溯之前做過的對(duì)node_modules的操作。
(3) To facilitate greater visibility of tree changes through readable source control diffs.
(4) And optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages. 對(duì)于之前通過npm安裝過的包,可以跳過元數(shù)據(jù)的解析,優(yōu)化安裝過程。
package.json 里 && 操作符的用法
使用&&時(shí),會(huì)運(yùn)行第一個(gè)命令,如果沒有出錯(cuò),則運(yùn)行第二個(gè)命令。 這就像一個(gè)邏輯與。
但是,使用 & 將在后臺(tái)運(yùn)行命令。 所以在你的第二個(gè) package.json 中,npm run build 將開始在后臺(tái)運(yùn)行,然后 npm run exe 也會(huì)運(yùn)行,不管第一個(gè)命令發(fā)生了什么。
總結(jié)
以上是生活随笔為你收集整理的nodejs项目的package-lock.json文件的用途的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 神级破解!安卓成功跑上iOS模拟器:部分
- 下一篇: 什么是npm package