Skip to content

Instantly share code, notes, and snippets.

@soofstad
Last active January 25, 2020 06:00
Show Gist options
  • Save soofstad/de03c9d4a281c45c70a620069d32cfa6 to your computer and use it in GitHub Desktop.
Save soofstad/de03c9d4a281c45c70a620069d32cfa6 to your computer and use it in GitHub Desktop.
How to: Equinor private NPM registry

How to: Equinor private NPM registry

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.

Login

CLI

Requirements: Have a Github account that is a member of the Github organization Equinor

  1. Create a personal access token on Github with the read:org scope
  2. Run npm login --registry https://npm.equinor.com
    Username: {Your Github username}
    Password: {The personal access token}
    Email: {Whichever you prefer}

Web

You can browse the registry on https://npm.equinor.com. Use you Github username, and the access token as password.

Install

To install a package from this registry;
npm install @equinor-internal/myPrivatePackage --registry https://npm.equinor.com

Publish

Private

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.

Public

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.

Tips and Tricks

  • 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.
@vnys
Copy link

vnys commented Feb 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment