繁体   English   中英

如何在使用 git remote url 进行 npm install 时指定注册表?

[英]How to specify registry while doing npm install with git remote url?

我希望能够使用此处指定的 URL 克隆 git 存储库

<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish>]

我收到一条错误消息

npm 错误! 404 注册表为https://registry.npmjs.org/XYZ 上的GET 返回 404

所以我也应该能够在做的时候指定注册表,因为模块应该从内部存储库中获取。

是否可以在使用git remote url进行npm install指定注册表

npm从命令行、环境变量和 npmrc 文件中获取其配置设置。 您可以尝试在 npmrc 文件中指定注册表,并在命令行中指定模块。 要更改注册表,您可以使用命令:

npm config set registry <registry url>

您还可以在--参数的帮助下更改配置。 --foo bar放在命令行上--foo bar foo 配置参数设置为“ bar ”。 所以你可以尝试这样的事情:

 npm install http://git.repo.url --registry=https://your.registry.local/

不是最好的方法,但如果您使用的是 mac 或 linux,您甚至可以为不同的注册表设置别名。

##############NPM ALIASES######################
alias npm-default='npm config set registry https://registry.npmjs.org'
alias npm-sinopia='npm config set registry http://localhost:4873/'

是的,您需要使用:

npm config set registry <registry url>.

确保从公司内部的注册表安装包。

如果您正在执行npm -i -g ,则这是全局安装。

你需要做:

npm -g config set registry <registry url>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM