VGTech is a blog where the developers and devops of Norways most visited website share code and tricks of the trade… Read more



Are you brilliant? We're hiring. Read more

NPM, Travis, Node 0.8 and the “Caret Operator”

JS

If you have a node.js project that you want to have tested using Travis-CI, you may run in to a problem if you want to support node <= 0.8. The reason for this is the new caret operator, which was introduced in node-semver.

This module is used by npm to figure out how to resolve versions for your dependencies, and while it’s a great idea, it fails to work on older node versions without upgrading npm first. It’s actually fairly trivial to fix this, however.

In your .travis.yml-file, simply define:

Show code
before_install:
  - npm install -g npm@~1.4.6

This will make sure a compatible version of npm is installed before running a regular npm install on your dependencies.

Note: While this will make Travis able to install your dependencies, people still running node <= 0.8 will have to go through the same routine, which you might want to make a note of in your README.

Developer at VG with a passion for Node.js, React, PHP and the web platform as a whole. espen.codes - @rexxars


0 comments

    Leave your comment