nodejs项目的package-lock.json文件的用途
在npm官網上有介紹: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.
當npm命令會修改node_modules樹形結構或者package.json時,package-lock.json文件會自動被創建。
作用有三:
(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操作的版本記錄文件,能回溯之前做過的對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. 對于之前通過npm安裝過的包,可以跳過元數據的解析,優化安裝過程。
package.json 里 && 操作符的用法
使用&&時,會運行第一個命令,如果沒有出錯,則運行第二個命令。 這就像一個邏輯與。
但是,使用 & 將在后臺運行命令。 所以在你的第二個 package.json 中,npm run build 將開始在后臺運行,然后 npm run exe 也會運行,不管第一個命令發生了什么。
總結
以上是生活随笔為你收集整理的nodejs项目的package-lock.json文件的用途的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 神级破解!安卓成功跑上iOS模拟器:部分
- 下一篇: 华为 P20 等 13 款设备启动鸿蒙