npm作用域包和私有registry

我们公司已经为我们的软件包build立了一个私有的npmregistry。 我们正在尝试设置一个angular2应用程序,并且所有包含的angular度包(从angular2教程页面)都被限定了范围。 问题是,当npm被设置为我们的私人registry,一个npm install给我们这个错误消息:

 npm ERR! Linux 4.4.8-boot2docker npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" npm ERR! node v4.3.0 npm ERR! npm v2.14.12 npm ERR! code E404 npm ERR! 404 no such package available : @angular/core npm ERR! 404 npm ERR! 404 '@angular/core' 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 'search-ui' 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! Please include the following file with any support request: npm ERR! /tmp/npm-debug.log 

如果我将它设置为默认的npmregistry,angular2拉好,但显然失败时,试图下载私人包。

我还没有确定这是否是一个整体angular2的东西(在包pipe理器中的一些权限)或只是所有范围的软件包(不知道其他范围的软件包存在)。 然而,我已经尝试了各种各样的东西来得到整套软件包无法安装(比如使用git repo而不是只能在不能接受的特定情况下运行的软件包版本)。 当我尝试将其部署到Docker容器中或在本地运行(主要关心容器的情况)时,会出现此错误。

有没有其他人遇到过这个问题? 如果这个有点含糊,我很抱歉,如果需要更多的信息,请随时发表评论。

正如NPM 在文档中所说的那样 ,所有私有包都是作用域的,范围可以与自定义registry相关联。

因此,如果您的私有包是@myPrivateScope/aPrivatePackage ,则可以通过@myPrivateScope/aPrivatePackage添加到项目根目录下的.npmrc文件来解决问题:

 @myPrivateScope:registry=http://my.private.registry.com 

等号后面的url是私人registry的地址。

你可以在https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry上find其他方法来完成这个关联和关于它的更多信息。