how to use Node along with other language on Travis CI

If you're setting up your .travis.yml file for running tests in a language that is not Javascript, but you still want to run some JS code or install some npm module you still can do that. node and npm are available as commands in the Travis environment, so you can use them on your install or before_script directives.

However, the nodejs version that comes by default is 0.10.x, and perhaps you need something newer.

You can't install with apt-get or with npm install -g n, because they need sudo, which will make your tests run very slowly and they don't work because they will install nodejs while your npm will still use node.

You also can't do nvm use directly, so you might think all hope is lost. But no, nvm is there. You just have to enable it. So add these lines to your .travis.yml:

  - . $HOME/.nvm/nvm.sh
  - nvm install stable
  - nvm use stable
  - npm install

And everything will work:

screenshot of the procedure