簡體   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