javascript - 当 "npm install"退出时 "node_modules"会做什么?

标签 javascript node.js npm

当您的项目目录中还有“package.json”和“node_modules”目录时,“npm install”的效果是什么?

它会覆盖现有模块吗?它会更新它们还是什么都不做?

最佳答案

来自 Algorithm Section在官方NPM Docs :


  • load the existing node_modules tree from disk
  • clone the tree
  • fetch the package.json and assorted metadata and add it to the clone
  • walk the clone and add any missing dependencies
    • dependencies will be added as close to the top as is possible
    • without breaking any other modules
  • compare the original tree with the cloned tree and make a list of
  • actions to take to convert one to the other
  • execute all of the actions, deepest first
    • kinds of actions are install, update, remove and move

所以不,它不会再次覆盖每个现有的包。
它获取所有包并比较包树和包文件之间的元数据。

关于javascript - 当 "npm install"退出时 "node_modules"会做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56293313/

相关文章:

javascript - 如何在 Fuel UX TreeView 中预选项目?

node.js - NodeJS Express : Repopulate form after error found

node.js - Azure Nodejs Web 应用程序在部署中缺少 npm 包

node.js - 无法弄清楚为什么docker compose up没有运行我的React JS App

javascript - 如何获取被点击元素的ID

Javascript:为什么 2 && 3 给出 3?

node.js - 需要更好地理解 npm 行为 (>= 7)

javascript - sails.js + underscore.js 无法将哈希项添加到数组中

node.js - 使用 GitHub 上的包作为依赖项,而无需安装 Git

javascript - 如何从 Typescript 模块导出 2 个项目