Set the repository for the scope "myscope"
npm config set @myscope:registry http://registry.corporation.com
Login at a repository and associate it with the scope "myscope"
npm adduser --registry=http://registry.corporation.com --scope=@myscope
Install a package "mylib" from the scope "myscope"
npm install @myscope/mylib
All together will be -
# Set the repository for the scope "myscope"
npm config set @myscope:registry http://registry.corporation.com
# Login at a repository and associate it with the scope "myscope"
npm adduser --registry=http://registry.corporation.com --scope=@myscope
# Install a package "mylib" from the scope "myscope"
npm install @myscope/mylib
If the name of your own package starts with @myscope and the scope "myscope" is associated with a different repository, npm publish
will upload your package to that repository instead.
You can also persist these settings in a .npmrc
file:
@myscope:registry=http://registry.corporation.com
//registry.corporation.com/:_authToken=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxx
This is useful when automating the build on a CI server
With all that being said, I highly recommend you keep learning!
Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.