I’m trying to install nvm and set the node version based on the .nvmrc in my app
I have tried almost every potential suggestion from all other threads and it doesn’t reliably work.
I have to highlight, that on 1 app I have got it working with this solution, however, trying the same exact method on another app it fails with exit status 3.
To be clear my build process fails at the following command as shown in my full config at the bottom:
nvm install
NODE_VERSION=$(node -v)
nvm alias default ${NODE_VERSION//v}
The failure is:
Exited with code exit status 3
CircleCI received exit code 3
This comment suggests that this could occur when one would source inside the same dir as an .nvmrc file, so, I have tried to cd .. then back in to the dir to nvm install after sourcing, however I get the same result Exited with code exit status 3:
- run:
name: Install nvm
command: |
cd ..
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV
echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV
- run:
name: Set node to version required by application for future circleci steps
command: |
cd ~/repo
nvm install
NODE_VERSION=$(node -v)
nvm alias default ${NODE_VERSION//v}
Full config without cding:
version: 2
jobs:
node-setup:
docker:
- image: circleci/python:3.7
working_directory: ~/repo
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Install nvm
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV
echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV
- run:
name: Set node to version required by application for future circleci steps
command: |
nvm install
NODE_VERSION=$(node -v)
nvm alias default ${NODE_VERSION//v}
- run:
name: node version
command: |
node -v
Additionally, Trying this solution results in a failure too, though I am aware this is for machine not docker:
#!/bin/bash -eo pipefail
node -v
/bin/bash: node: command not found
Exited with code exit status 127
CircleCI received exit code 127
Any help would be appreciated,
Thanks in advance,
Joe
