Create a GitLab(GL) access token
The first thing we need to do is create an access token in GL. In GL, under your profile, click on Access Tokens
in the sidebar. This will bring up a screen for us to create a new token under our profile.
- Name the token whatever you’d like. Example:
my-gds-token
. - You can leave the expiration blank.
- You can select all scopes.
- Press the
Create personal access token
button.
This will refresh the screen and present you with a shiny, brand-new access token. Copy it, we will be putting it to work.
Edit your .npmrc
We now need to tell npm
that we want to use a private repository when installing our package.
Here are two two ways we can do that:
- Open your terminal of choice and edit your local
.npmrc
file. - Add a
.npmrc
file to your currentnpm
project at the root level.
However you decide to add these credentials paste the following into the file.
@nielsen-media:registry=https://gitlab.com/api/v4/packages/npm/
@nielsen-media:registry=https://gitlab.com/api/v4/projects/36705211/packages/npm/
//gitlab.com/api/v4/packages/npm/:_authToken=YOUR_GL_ACCESS_TOKEN
//gitlab.com/api/v4/projects/36705211/packages/npm/:_authToken=YOUR_GL_ACCESS_TOKEN
registry=https://registry.npmjs.org/
always-auth=true
Note: Replace ACCESS_TOKEN
with the access token you created in GitLab.