Disclamer: This is just an example on how to do these tasks. You can configure npm/yarn in many ways to make life easier.
Feel free to experiment.
Requirements: Have a Github account that is a member of the Github organization Equinor
- Create a personal access token on Github with the read:org scope
- Run
npm login --registry https://npm.equinor.com
Username: {Your Github username}
Password: {The personal access token}
Email: {Whichever you prefer}
You can browse the registry on https://npm.equinor.com. Use you Github username, and the access token as password.
To install a package from this registry;
npm install @equinor-internal/myPrivatePackage --registry https://npm.equinor.com
To publish a private package, set the scope of the package to @equinor-internal.
So the name of the package becomes; @equinor-internal/myPrivatePackage
NB! Packages with no scope, OR a different scope, are readable by the world.
You can also publish a public package to this registry.
Simply ommit the "@equinor-internal" scope.
You have to login with a valid Equinor account to publish, but they can be accessed by everyone.
- You can set the default registry with;
npm set registry https://npm.equinor.com
The registry acts as a proxy, so requests for packages not in this registry will be forwarded to registry.npmjs.org - You can browse the registry on https://npm.equinor.com. Use you Github username, and the access token as password.
A short tip for new users: Using a password manager like Lastpass or the keychain on macOS will make it less of a hassle to use a token to login in a browser.