2016-07-04 28 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