My company has private scoped npm
modules ie the ones starting with @mycompanyscope/mymodule
. By defaults all scoped modules in npm are private so you have to login first before publish
npm login
Username:myusername
Password:**********
npm publish
The scoped module must have the property name
with a scope in the package.json
:
{
"name": "@mycompanyscope/mymodule"
}
and the private
key must be removed.
As soon as you login you get a token
in the .npmrc
file in your $HOME
folder, that is like
//registry.npmjs.org/:_authToken=00000000-0000-0000-0000-000000000000
scope=mycompanyscope
At this point everything is properly setup to publish
and install
in this machine. If you grant access to other users, they can do npm login
on their machines and get a token to work from there.
The problems come on the server side, depending on your server. On Heroku it should work as explained here .
My server environment is Azure Web Sites. According to some docs, you should upload your .npmrc
file to Azure during the deploying phase, and that would awesome, if I would have a way to get a token for that machine. If I try to login to Kudu PowerShell
, the fact is that I just cannot login, the login process hangs at some point:
Kudu Remote Execution Console
Type 'exit' then hit 'enter' to get a new powershell process.
Type 'cls' to clear the console
PS D:\home> npm login
Username: mycompany
Password: *********
Email: (this IS public) npm@mycompany.com
so that I cannot generate any token from this machine. So how can I grant access here to let the npm install
to run correctly for private scoped modules?
[UPDATE] Thanks to the answer below I was able to deploy the npm scoped module (@ mycompanyscope/myModule) to Azure Web Sites, creating the .npmrc
file in the project root folder (where the package.json
is) and then writing there the token obtained after the npm login
, and adding the registry
to the npmjs.org
registry:
//registry.npmjs.org/:_authToken=00000000-0000-0000-0000-000000000000
scope=mycompanyscope
@mycompanyscope:registry=https://registry.npmjs.org/
Have you tried to npm login
your private npm registry on your local machine, to generate a .npmrc
file in your node.js application, then deploy to Azure Web App with your application.
Please refer to https://blog.maartenballiauw.be/post/2015/10/13/working-with-a-private-npm-registry-in-azure-web-apps.html for more details.
Any update or further concern, please feel free to let me know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.