有没有办法在一个npmrc文件中configuration多个registry
这是我的问题。 我们有一个私人NPMregistry,只能在VPN中工作。 我想有一个后备registryhttps://registry.npmjs.org,这样当我脱离VPM时,它可以无缝工作。
PS目前我正在使用npmrc ,它在切换.npmrc文件之间做了很好的工作
您的.npmrc
文件中可以有多个registry作用域的软件包 。 例如:
@polymer:registry=<url register A> registry=http://localhost:4873/
@polymer
范围内的软件包将从https://registry.npmjs.org收到,其余的将从您的本地NPM收到。
在版本4.4.1上,如果您可以更改软件包名称,请使用:
npm config set @myco:registry http://reg.example.com
@myco是你的软件包范围。 你可以这样安装包:
npm install @ myco / my-package
ref: https : //docs.npmjs.com/misc/scope
对于那些也在寻求authentication解决scheme的人,我会在范围包解决scheme上添加一个你可以在.npmrc
文件中有多行的解决scheme:
//internal-npm.example.com:8080/:_authToken=xxxxxxxxxxxxxxx //registry.npmjs.org/:_authToken=yyyyyyyyyy
每行代表不同的NPMregistry
不是最好的方法,但是如果你甚至在windows中使用mac或者linux,你可以为不同的registry设置别名。
##############NPM ALIASES###################### alias npm-default='npm config set registry https://registry.npmjs.org' alias npm-sinopia='npm config set registry http://localhost:4873/'
有些步骤可以尝试。 (它是如何在我的工作场所做的)
- 使用两个(或更多)存储库源地址创build一个registry组。 一个是你的内部私人,另一个是npmjs的代理,优先考虑内部的一个。
- 使该组成为.npmrc文件中的registry。 这种方式npm将总是试图从内部得到它,如果没有find它从代理
希望有所帮助。