简体   繁体   English

npm范围包和私有注册表

[英]npm scoped packages and private registry

Our company has set up a private npm registry for our packages. 我们公司为我们的软件包设置了一个私人npm注册表。 We are trying to set up an angular2 application and all angular packages that are included (from the angular2 tutorial page) are scoped. 我们正在尝试建立一个angular2应用程序,并且所包含的所有角度软件包(来自angular2教程页面)都已确定范围。 The issue is while npm is set to our private registry, an npm install gives us this error message: 问题是当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

If I set it to the default npm registry, angular2 pulls fine but obviously fails when trying to download the private package. 如果我将其设置为默认的npm注册表,则angular2正常运行,但在尝试下载私有软件包时显然失败。

I haven't determined whether this is an overall angular2 thing (some permissions in the package manager) or just all scoped packages (not sure what other scoped packages exist). 我还不确定这是整体的angular2东西(包管理器中的某些权限)还是仅仅是所有作用域的包(不确定是否存在其他作用域的包)。 I have, however, tried all kinds of things to get the full set of packages to install to no avail (such as using a git repo instead of a package version which works in only specific cases which is not acceptable). 但是,我尝试了各种方法来使整套软件包无法安装(例如使用git repo而不是仅在特定情况下不可接受的软件包版本)。 And this error comes when I try to deploy this into either a Docker container or run locally (mostly concerned about the container case). 当我尝试将其部署到Docker容器中或在本地运行(主要关注容器的情况)时,就会出现此错误。

Has anyone else ever run into this problem? 有没有其他人遇到过这个问题? As well I apologize if this a bit vague so feel free to post a comment if more information is needed. 我也对此表示歉意,如果需要更多信息,请随时发表评论。

As NPM says in the documentation , all private packages are scoped, and scopes can be associated to custom registries. 正如NPM 在文档中所说,所有私有软件包都具有作用域,并且可以将作用域与自定义注册表关联。

So, if your private package is @myPrivateScope/aPrivatePackage , your problem could be solved by adding the following line to the .npmrc file on the root of your project: 因此,如果您的私有软件包是@myPrivateScope/aPrivatePackage ,则可以通过@myPrivateScope/aPrivatePackage添加到项目根目录中的.npmrc文件中来解决您的问题:

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

Where the url after the equals sign is the address to your private registry. 等号后的网址是您专用注册表的地址。

You can find other ways to do this association and more information about it on https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry 您可以在https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry上找到执行此关联的其他方法以及有关此信息的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM