gpt4 book ai didi

npm - 为什么我必须运行 "npm install"两次才能成功安装我的包

转载 作者:IT老高 更新时间:2023-10-29 00:12:43 29 4
gpt4 key购买 nike

我第一次“npm install”package_1 时,出现以下错误。

npm ERR! path C:\Users\john_\Documents\GitHub\why_npm_nesting_fails\package_1\node_modules\.staging\bignumber.js-55edd243

我不使用“bignumber”,所以假设它是一个 MySQL 依赖项。我第二次“npm install”package_1,它通过了。

added 2 packages and audited 30 packages in 0.722s

它与 MySQL 有关,因为在删除此依赖项后,一切都在第一次运行。

这是依赖关系图:

enter image description here

可以在以下位置找到精简项目 https://github.com/johngrabner/why_npm_nesting_fails只有 4 个 package.json 文件,每个文件 7 行,包括 { } 演示了这个问题。即:4 个文件,每个文件 1 行,说明了这个问题。

自从第一个“npm install”失败以来,这个问题使我无法将我的项目干净利落地放入 docker 容器中。解决方法安装“package_4”,然后安装“package_3”等等,但有效我担心我不理解会回来咬我的东西。

上述问题在 Windows 和 Docker Node:9.4 上均出现。

最佳答案

您绝对应该始终保留您的 package-lock.json

以下是对该文件的详细描述及其如此有用的原因:package-lock.json -- A manifestation of the manifest

重点是:

  • Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies

  • Optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages

通过删除此文件,您将(有点)混淆 NPM。

保留 package-lock.json 文件会更容易,然后处理如果不这样做会出现的所有问题:)


package-lock.json

"This file is intended to be committed into source repositories"

( https://docs.npmjs.com/files/package-lock.json )

关于npm - 为什么我必须运行 "npm install"两次才能成功安装我的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53853410/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com