2016-07-04 30 views
2

我们公司已经为我们的软件包建立了一个私人npm注册表。我们正在尝试设置一个angular2应用程序,并且所有包含的角度包(来自angular2教程页面)都是作用域的。问题是当NPM设定为我们的私人注册,一个npm install为我们提供了这样的错误消息:npm scoped packages和private registry

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容器中或在本地运行时(主要关注容器案例),会出现此错误。

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

回答

2

由于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

+0

非常感谢!那就是诀窍。我无法真正包围我的头,但我做了更多的挖掘,并最终发现了这一点,这些消息来源解决了我的困惑(以及这个更简洁的答案)。 – Perley