You can use your own Docker image, make it build on top of the official CircleCI one and update the npm version there until the official image is updated
Note about my research on npm ci and its speed:
It should be significantly faster than npm install however
npm ci always deletes and re-fetches all dependencies as specified in package-lock.json . This should in theory prevent any possible corruption of the already installed dependencies.
which is not compatible with CircleCI caches.
Caching node_modules between builds and running npm install should be way faster than npm ci.
Note you can cache the npm cache!
It’s is stored in /root/.npm. We are successfully using npm ci with relatively quick install times using the following save_cache
# ...
docker:
- image: circleci/node:latest
steps:
# ...
- run:
name: updating npm...
command: npmv=$(echo $(npm -v) | head -c 1); if [ "$npmv" -lt "6" ]; then sudo npm i -g npm; else echo "Node.js Docker Team finally decided to include npm v6+ in latest image; you can remove this script now"; fi
- run:
name: installing dev dependencies...
command: npm ci
# ...
I wrote this script to update npm only if it’s < 6.0.0 so I can use npm ci, and skip the update if the docker image already includes npm v6.0.0+. Hopefully, I’ll see the note once npm is updated in the docker image and I can remove the script.
I’m a beginner at circleci and yml, but I think this’ll work for the time being.
I spent some time figuring the npm command not found error and it turns out it was the sudo the cause so no need to use sudo:
command: npmv=$(echo $(npm -v) | head -c 1); if [ "$npmv" -lt "6" ]; then npm i -g npm; else echo "Node.js Docker Team finally decided to include npm v6+ in latest image; you can remove this script now"; fi