hot to configure npm to use npm, Inc.’s private registry?


(Johngrabner) #1

https://docs.npmjs.com/misc/registry says
npm is configured to use npm, Inc.’s public registry at https://registry.npmjs.org by default.
What registry setting for private package hosted by npm inc?

https://docs.npmjs.com/misc/scope says Scopes can be associated with a separate registry. This allows you to seamlessly use a mix of packages from the primary npm registry and one or more private registries, such as npm Enterprise.

The " npm Orgs Best for smaller teams and organizations" is not enterprise, but not public, so what do i use ?

When I try to “npm install @myprivatescope/mypackage”, i get the error " Error: 404 Not Found:"

So i’m guessing i need to set something to use these private packages.

bts, npm loging does not do it.


(Lars Willighagen) #2

Private packages are hosted on the main registry (as opposed to private/custom registries like npm Enterprise). However, they require proper authentication. Did you say logging in didn’t work?


(Johngrabner) #3

Thank you for the suggestion. I finally got it working.

Looks like I messed up the

~/.npmrc

file by trying to set the registry, since the documentation did not say anything about private packages being stored the same place as public. I deleted the registry line, and things started working.

Yes, I did a

npm login

, but did not see any documentation about needing a login and it did not help because the messed up

~/.npmrc
trying to set the registry.

Q: I see a boatload of tokens on https://www.npmjs.com/settings/johngrabner/tokens

A token is generated every time I log in? Do these ever expire or do last accumulate over time and last forever?

Q; is there where I can make suggestions for the documentation? If so,

https://docs.npmjs.com/misc/scope

Line “If you wish, you may associate a scope with a registry; see below.”
Add “This is not necessary for private packages hosted by npm”

Line " You can then change the access permissions, if desired, with npm access or on the npmjs.com website."
Add "Alternatively, to post to your private scope, make sure the name in package.json included your scope as in @blawblaw/mypackage, then npm login, and npm publish.

https://docs.npmjs.com/configuring-your-registry-settings-as-an-npm-enterprise-user

add “not required for npm Orgs private packages”

https://docs.npmjs.com/misc/scope.html#installing-scoped-packages

Line: “Installing scoped packages”
add "Must have an auth token in the ~/.npmrc file before issuing these commands. The easiest way to add this token is to issue the “npm login” command


(Kiera Manion-Fischer) #4

Hi John,

I’m glad you were able to solve the issue. We do read and track docs suggestions here. Yes, a new token is generated when you log in. You can learn more about tokens here: https://docs.npmjs.com/about-authentication-tokens Tokens expire when you log out or if you delete them on that page or through the CLI.