Switch nodejs version on machine executor [solved]

Hi,

we had some problems upgrading nodejs on machine executors, so we wrote up about the recipe we followed:

https://www.cloudesire.com/how-to-upgrade-node-on-circleci-machine-executor/

Hello, thank you for your recipe. I didn’t know nvm is installed by default in machine executor.

Unfortunately it does’t work properly for me.
Node 8.11.3 is installed for me within the same step, but in next step I have node 6.x again

      - run:
          name: Install  Node.js 8.9.1 with build in nvm tool
          # https://www.cloudesire.com/how-to-upgrade-node-on-circleci-machine-executor/
          command: |
            export NVM_DIR="/opt/circleci/.nvm"
            [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
            nvm install v8.11.3 && nvm use v8.11.3 && nvm alias default v8.11.3
            node -v

      - run:
          name: Check node version
          command: |
            node -v

which outputs

# first step:
Now using node v8.11.3 (npm v5.6.0)
Now using node v8.11.3 (npm v5.6.0)
default -> v8.11.3
v8.11.3

# and second step:

v6.1.0
1 Like

OK later I solved it by implementing the code from this post: How to change node version in CircleCI 2.0?

I’ve fixed the blog post https://github.com/ClouDesire/docusaurus/commit/ee11951336be3f64f5c6a25a8047bfeecc29fb43
The problem was that you need to load the nvm environment on every run.

1 Like

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