mark
mark

Reputation: 2063

Multiple Node.js Versions in CircleCI

How can I configure my circle.yml file to test against multiple Node.js versions?

I want to be able to do something like this:

---
machine:
  node:
    - 4.0.0
    - 5.0.0

Upvotes: 3

Views: 881

Answers (2)

appplemac
appplemac

Reputation: 382

There is unfortunately no built-in way to do this, so using nvm would be the only option.

You could do something like this in your circle.yml:

machine:
  node:
    version: 0.12

test:
  override:
    - test that you want to run with v0.12
    - nvm use 4.0; test you want to run with v4

Example copied from the response right here.

Upvotes: 4

m453h
m453h

Reputation: 114

Use NVM here is where you can get the package

https://www.npmjs.com/package/nvm

Here is an extract of a tutorial that might help you on your way

Installation You can read the installation steps on the nvm NPM page. There are only two easy steps for installation and configuration.

Using nvm If you work with a lot of different Node.js utilities, you know that sometimes you need to quickly switch to other versions of Node.js without hosing your entire machine. That's where you can use nvm to download, install, and use different versions of Node.js:

nvm install 4.0

At any given time you can switch to another with use:

nvm use 0.12

If you want to check out what versions of Node.js are installed on your machine, you can use the ls option:

nvm ls

/*
    v0.10.26
    v0.10.36
->  v0.12.7
    v4.2.1
    system
*/

If you're done with a version and want it gone, you can do that too:

nvm uninstall 0.10

nvm has been a lifesaver for me, especially when troubleshooting issues in projects where the user may have more than one Node.js version. If you're looking to get into Node.js development, one of the first tools you get should be nvm!

Source:https://davidwalsh.name/nvm

Upvotes: 1

Related Questions