当您的项目目录中还有“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/