Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Private npm modules in Travis Pro

Log into npm using the account you want to use for accessing the private modules on Travis

$ npm login

Then copy the npm auth token from your ~/.npmrc file. It's the string after "//registry.npmjs.org/:_authToken=".

In Travis, add the NPM_TOKEN environment variable to the settings with the token value.

In your .travis.yml file:

language: node_js

node_js:
  - 4

before_install:
  - printf "//registry.npmjs.org/:_authToken=${NPM_TOKEN}\n" >> .npmrc
@jgrund

This comment has been minimized.

Copy link

commented Sep 28, 2015

Could also do:

- npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN

In before_install

@fyockm

This comment has been minimized.

Copy link

commented Sep 30, 2015

Any reason not to simply have an .npmrc file in your project directory with a single line? Why set it before install every time?

//registry.npmjs.org/:_authToken=${NPM_TOKEN}
@paralin

This comment has been minimized.

Copy link

commented Aug 11, 2016

@fyockm Security, you don't want tokens in the repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.