Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 245
mark Avatar asked Jun 19 '26 07:06

mark


2 Answers

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.

like image 119
appplemac Avatar answered Jun 20 '26 22:06

appplemac


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

like image 36
m453h Avatar answered Jun 20 '26 22:06

m453h



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!