npm作用域包和私有注册表

时间:2016-07-04 16:22:04

标签: angularjs node.js docker npm

我们公司为我们的软件包设置了一个私有的npm注册表。我们正在尝试设置angular2应用程序,并且包含的​​所有角度包(来自angular2教程页面)都是作用域的。问题是当npm设置为我们的私有注册表时,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

如果我将它设置为默认的npm注册表,angular2会很好,但在尝试下载私有包时显然会失败。

我还没有确定这是一个整体angular2事件(包管理器中的一些权限)还是只是所有范围包(不确定存在哪些其他范围包)。但是,我已经尝试了各种各样的东西来安装完整的软件包(如使用git repo而不是仅适用于特定情况的软件包版本,这是不可接受的)。当我尝试将其部署到Docker容器或本地运行时(主要关注容器的情况),就会出现此错误。

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

1 个答案:

答案 0 :(得分:4)

正如NPM所说的那样in the documentation,所有私有包都是作用域的,并且作用域可以与自定义注册表相关联。

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

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

等号后面的网址是私人注册表的地址。

您可以在https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry

找到进行此关联的其他方式及其相关信息