Platform agnostic library which provides a robust solution for maintaining credentials in your npmrc files
Last updated 6 months ago by jstevans .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install devops-npm-auth 
SYNC missed versions from official npm registry.


Platform agnostic library and acompanying oauth service enabling developers to easily obtain and use tokens for authorizing NPM feeds in VSTS

CircleCI code style: prettier


While not necessary, better-vsts-npm-auth was built to be used as a global module. npm i -g better-vsts-npm-auth


Command line

Best for ad-hoc cases. The CLI comes with fully descriptive help docs, you can run them via better-vsts-npm-auth --help.


Provided for direct integration with application-specific tooling. On my team, we use this in our preinstall script for our project to harden our system against annoying token expirations needlessly breaking our development mojo.


const vstsAuth = require('better-vsts-npm-auth');
const input = require('input');
  .then(() => console.log('woohoo! No more annoying 401s'))
  .catch(e => {
      // we can catch AuthorizationError and prompt our users to
      // authorize the Stateless VSTS NPM OAuth application
      // (or your own application, if you specify an alternate
      // clientId in your config, which you're welcome to do)
      if (vstsAuth.isAuthorizationError(e)){
          // fail if we're running in a lab
          if (process.env['BUILD_BUILDID'] || process.env['RELEASE_RELEASEID']){
              return Promise.reject(e);

          // wait for user input if we're running on a dev box
          // note - I like the input package, but feel free to get your user
          // input however you'd like
          return input.text('paste your refresh_token:').
            then(token => {

                // not necessary, but nifty if you want to create a
                // seamless local dev startup experience by re-running

Dependency on stateless-vsts-oauth

VSTS's OAuth flow is documented here. It requires an internet-facing service to complete the token exchanges. While you're welcome to use an existing service if you have one or build your own if you're so inclined, you can also use this service as-is. It's hosted at

Prior art

While incomplete - the lack of support for *nix systems was perplexing - vsts-npm-auth laid the foundation for this project in principle.

Current Tags

  • 5.0.0                                ...           latest (6 months ago)

3 Versions

  • 5.0.0                                ...           6 months ago
  • 5.0.0-alpha-1                                ...           6 months ago
  • 5.0.0-alpha                                ...           6 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (7)
Dev Dependencies (14)
Dependents (0)

Copyright 2014 - 2017 © |