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

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:

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.

Read more from the Software engineering category
SUBSCRIBE TO OUR UPDATES
Menu