npm - npm install 不考虑 package-lock.json 中的注册表/解析路径
问题描述
从私有注册表安装软件包非常简单:
npm install my-package --registry https://<private-registry-url>
这将添加一个条目到package-lock.json
:
"my-package": {
"version": "1.0.0",
"resolved": "https://<private-registry-url>/<some_path>/my-package-1.0.0.tgz",
"integrity": "sha1-Pjs/y9sEp49/OC8+8eEZFdwT3BQ="
},
到目前为止一切顺利,一切都符合预期。
现在的问题是,当您想使用npm install
. 这将失败并出现以下错误:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/my-package - Not found
npm ERR! 404
npm ERR! 404 'my-package@1.0.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'app'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<user>\AppData\Roaming\npm-cache\_logs\2019-08-06T08_33_05_103Z-debug.log
因此它尝试my-package
从公共 npm 注册表 ( https://registry.npmjs.org/my-package
) 中获取,但由于my-package
位于私有注册表中,因此当然会失败。
现在这真的打破了我对package-lock.json
.. 的理解。 npm 不应该package-lock.json
查看以前的包在哪里解决吗?相反,它只是假设它必须在公共注册表中。
另一个有趣的事情是,一旦您再次手动安装带有--registry
标志的软件包,它就可以工作:
npm install my-package --registry https://<private-registry-url> && npm i
之后它每次都会工作,直到您升级版本my-package
或切换设备..
我也尝试了npm ci
命令但没有成功(同样的错误)。
那么如何从私有注册表正确安装软件包,以便可以轻松地将它们安装在任何其他设备上使用npm install
?
解决方案
推荐阅读
- python - 检查列表中的相等值并将它们设置为 0
- c - C 函数,它接收一个结构,并使其在函数外部发生变化,即使该结构没有作为指针发送
- php - PHP 联系表单将使用代码进入页面
- github - 重命名 Github 存储库
- reactjs - React Redux Firebase - onAuthStateChanged 延迟阻止使用生命周期方法
- python - python for循环中追加函数的机制
- jenkins - 在共享库中重构 jenkins post 块
- r - str_detect,使用特定模式验证电话号码
- asp.net-web-api - 不同类型的WebApi2 FromBody RequestMessage
- php - PHP 邮件程序在本地工作,但不能在实时服务器上工作