[英]How to force NPM to use a locally hosted registry
When you install a node module, NPM gets the package from the default registry:安装节点模块时,NPM 从默认注册表中获取包:
https://registry.npmjs.org
My company is hosting its own node registry and I want use it.我的公司正在托管自己的节点注册表,我想使用它。 How can I force NPM to use this local registry.
如何强制 NPM 使用此本地注册表。
I don't want to use npm install --registry
option.我不想使用
npm install --registry
选项。
Is there a way to make all the users on a specific machine to use this internal registry?有没有办法让特定机器上的所有用户都使用这个内部注册表?
What worked for me was, I ran following command :对我有用的是,我运行了以下命令:
npm config set registry PATH_TO_YOUR_LOCAL_REGISTRY
Another option is to create a .另一种选择是创建一个 .
NPMRC
file and put it into your project root directory. NPMRC
文件并将其放入您的项目根目录。 As mentioned in this link project specific npmrc file will take the highest priority & it will override other configuration.正如此链接中提到的,特定于项目的 npmrc 文件将具有最高优先级,并且会覆盖其他配置。 In this file just update the registry.
在此文件中只需更新注册表。
In npmrc file, add following:在 npmrc 文件中,添加以下内容:
registry = "https://path to local registry"
You don't have to use the --registry
option–you can just set the package.json
to point to your internal repository [0]:您不必使用
--registry
选项——您只需将package.json
设置为指向您的内部存储库 [0]:
Set "private": true
in your package.json
to prevent your package from being published, and set:在
package.json
设置"private": true
以防止您的包被发布,并设置:
"publishConfig": {
"registry": "http://my-internal-registry.local"
}
to force it to be published only to your internal registry.强制它仅发布到您的内部注册表。
[0] https://docs.npmjs.com/misc/registry#i-dont-want-my-package-published-in-the-official-registry-its-private [0] https://docs.npmjs.com/misc/registry#i-dont-want-my-package-published-in-the-official-registry-its-private
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.