Node.js packages

You can configure Buddy to use private modules from the npm registry in your projects. This article will tell you how.

Download login

Log in to the npm locally. The user you’re logging with must have access to the private packages that you want to use:

bash
npm login $$

Once you do it, display the file contents:

bash
cat ~/.npmrc $$

Now copy the auth token. You will find it in the file after such string:

//registry.npmjs.org/:_authToken=

Add token to Buddy as ENV VAR

In Buddy, go to Variables, Keys & Assets and add a new variable:

Image loading...Adding new variable

Add the variable with the value of the acquired token:

Image loading...Saving token as environment variable

Configure npm

Now, go to the Node action which requires private packages in your dependencies. Adjust the npm install command as follows:

bash
npm config set //registry.npmjs.org/:_authToken $NPM_AUTH_TOKEN npm install $$$
Hint
To set your company's registry as default, use npm config set registry followed by the company registry address

GitHub Private Package registry

To authenticate into GitHub, make sure your .npmrc file has the following structure:

js
@MY_ORG:registry=https://npm.pkg.github.com/MY_ORG //npm.pkg.github.com/:_authToken=YOUR_TOKEN

Last modified on Sep 23, 2024