Perley Perley - 26 days ago 9
Node.js Question

npm scoped packages and private registry

Our company has set up a private npm registry for our packages. We are trying to set up an angular2 application and all angular packages that are included (from the angular2 tutorial page) are scoped. The issue is while npm is set to our private registry, an

npm install
gives us this error message:

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.

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). 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). And this error comes when I try to deploy this into either a Docker container or run locally (mostly concerned about the container case).

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.

Answer Source

As NPM says in the documentation, all private packages are scoped, and scopes can be associated to custom registries.

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: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