npm Enterprise and Jenkins

Recently @ FX Networks, we began injecting npm private modules via npm Enterprise into some of our applications. This has allowed us to maintain a very clean and modularized development environment that is much easier to manage.

One issue that we ran into initially when integrating npm Enterprise w/Jenkins was that builds that were previously passing started failing once we added our scoped packages to the mix.

+ npm install @fx/some-private-module
npm ERR! Linux 3.13.0-48-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "@fx/some-private-module"
npm ERR! node v0.12.3
npm ERR! npm v2.9.1
npm ERR! code E404
 
npm ERR! 404 Not found : @fx/some-private-module
npm ERR! 404 
npm ERR! 404 '@fx/some-private-module' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'fx-node-app'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

We had successfully authenticated to the private registry from the Jenkins server but the builds were still failing. Since npm Enterprise is a new offering, search results on using it w/Jenkins were scarce. After a chat w/Ernie @ npm, who pointed us to a couple of useful articles, we added the following to our build configs to resolve the error above:

cp /home/tomcat/.npmrc .npmrc

Adding that in the Execute Shell task just before npm install ensures that the authentication token is available for validation once we npm install. Now all of the builds involving our private npm registry are stable once again.

Leave a Reply

Your email address will not be published. Required fields are marked *