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:
- You can leave the expiration blank.
- You can select all scopes.
- Press the
Create personal access tokenbutton.
This will refresh the screen and present you with a shiny, brand-new access token. Copy it, we will be putting it to work.
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
- Add a
.npmrcfile to your current
npmproject 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
ACCESS_TOKEN with the access token you created in GitLab.