Unable to set node version with Circle 2.0

I have tried out various circleci images from docker, and regardless of which one I choose the node version is always the same, v4.2.6.

Can anyone provide any guidance on how to change the version of node.js?

Thank you.

1 Like

I have the same issue.

My circle.yml is as follows

version: 2

      # specify the version you desire here
      - image: circleci/node:9.4.0
      - checkout

      # Download and cache dependencies
      - restore_cache:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: Install dependencies
          command: npm install

      - save_cache:
          key: v1-dependencies-{{ checksum "package.json" }}
            - node_modules

      # run tests!
      - run:
          name: Linter
          command: npm run lint
      - run:
          name: Unit tests
          command: npm run test:unit
      - run:
          name: Integration tests
          command: npm run test:server

But the tests fail and in the logs I see

ERR! node v4.2.6
npm ERR! npm  v2.14.12

I would guess this is a standard Linux debugging issue, and nothing to do with CircleCI per se. I wonder if there are several npm binaries in this container, and one has to use a fully-qualified path to get the right one?

If that does not work, you can always roll your own, which will, obviously, only contain the version you install. It is helpful to set this up as a separate build process, and then push to a public/private registry on successful image build.

So just for the record, I worked out my issue. The file is meant to be called .circleci/config.yml not .circleci/circle.yml

The node version is being set correctly now.

1 Like

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