Nodejs version




I’ve switched on 2.0 toda.

I can see that build environment is not ubuntu anymore but debian jessie.

Debian include a very very old version of nodejs (0x thus actual is 6x).

Could build use a recent version of nodejs ? how ?



That sounds like you’re using the machine executor, which might not be best for you. You should use the docker executor with a NodeJS Docker image.


In fact, I’m using the docker executor.

However, my application is in PHP, thus I use circleci/php:5.6

but to check my javascript files I have to install npm … on my instance


We have some php-node images that should work for you.


If I’m using circleci/php:5.6.31-cli-node-browsers, how can I know/lock the version of node that’s being used?


If you keep using that exact tag, the NodeJS version shouldn’t change.

You can know which version you’re using by running node --version from within the container or digging through the source here:


I actually think the NodeJS version might change after all. In that case, I’d suggest 1 of three things.

  1. Use the PHP image without NodeJS and install the NodeJS version you want.
  2. Use the NodeJS image and install the PHP version you want.
  3. Go with your own image that is exactly as you want it.

Update 2

A colleague of mine mentioned you could use the Docker image SHA instead of the tag and that will ensure the image stays the same, meaning the NodeJS version won’t change.


Ah great idea. What I was trying to solve was this issue: How to specify node version with circleci/php:5.6.31-cli-node-browsers?. I will possibly just use the image SHA instead to ensure node doesn’t change.

All I really want to do is to be able to set my cache name to something like:

v1-webroot-npm-cache-{{ node --version}}-{{ checksum "./app/webroot/package.json" }}
# or
v1-webroot-npm-cache-{{ .Environment.NODE_VERSION }}-{{ checksum "./app/webroot/package.json" }}

but those don’t seem to work even though I’ve set the environment variable for NODE_VERSION and it is echoing out properly elsewhere in the process.

  container_config: &container_config
    working_directory: ~/container
      - image: circleci/php:5.6.31-cli-node-browsers
      NODE_VERSION: node --version


I ended up going with the following solution (after going through the dark path of trying to figure out why environment variables weren’t working). My first step prints the node version to a file then persists it to the workspace. I then use this file as the checksum in the above scenario:

    <<: *container_config
      - *attach_workspace
      - run:
          name: "Generate nodejs version key"
          command: node --version > ~/workspace/.CIRCLECI_NODE_VERSION
      - persist_to_workspace:
          root: *workspace_root
            - ./.CIRCLECI_NODE_VERSION

We will lock down the version of nodejs using a different image at a later point, but this will definitely suffice for now. Thanks for the help and ideas.

How to include Node major version in cache key

For the record, NodeJS variants of CircleCI Docker images will include the latest LTS release of NodeJS.

Keep in mind, latest as in what’s available on NodeJS’s official Docker image, not their website. Sometimes they can take a day or two to publish on Docker Hub for some reason.


That’s fine, I just need to know when the version is updated so I know whether I need to rebuild node-sass. In the future we will use a node specific image to lock the version, but needed more of a proof of concept for the time being.


The only thing I can think of is to have Bash fail your build when the NodeJS version fails.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.