Knowledge

How to use private npm 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:

npm login

Once you do it, display the file contents:

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 environment variable

Go to the Project Options in Buddy. In the right menu select Environment variables and add the variable with the value of the acquired token.

Adding token as environmental variable
Adding token as environmental variable

Configure npm

Dependencies are fetched at the moment of executing the npm install command.

If you have private packages in the dependencies, execute:

npm config set //registry.npmjs.org/:_authToken $NPM_AUTH_TOKEN
npm install

Get started now

14 days of unlimited trial. No credit card required.