Using Node.JS 4.0 on CircleCI

Node.JS 4.0 has been released and currently needs gcc 4.8 or newer to compile certain modules. The current circle image uses gcc version 4.6. Because of this you might see the following error when trying to use Node.JS 4.0:

This version of node/NAN/v8 requires a C++11 compiler

As a workaround, in order to use Node.JS 4.0 you will need to add the following to your circle.yml file.

machine:
  node:
    version: 4.0.0

dependencies:
  override:
    - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update
    - sudo apt-get install -y gcc-4.9 g++-4.9
    - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 10
    - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 10
    - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
    - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

test:
  override:
    - gcc --version

Credits: Originally posted by @kimh

4 Likes

of course the

test:
  override:
    - gcc --version

is just there to show that gcc version is 4.9.0
you’ll probably want to omit the test, override portion to use your own npm test script

1 Like

Thanks! I’ve been getting ELIFECYCLE errors compiling Microtime which apparently are caused by this. Can you update the thread when the new gcc install is no longer necessary (eg, your node 4.x images should already include the right compiler)

When will this workaround for node 4.X not be required? Where can we expect the announcement?

You can sign up for announcements regarding image updates here https://discuss.circleci.com/c/announcements

1 Like

bad news: this workaround seems to throw errors now.
good news: it doesn’t seem like this workaround is needed any longer.

please confirm?