Reputation: 15
In Dockerfile we have command: CMD ["npm", "run", "start"]
. But when running it in CI where actual image is built, npm tries to update itself (since we are using not the latest npm version). And fails with insufficient permission error.
Base image defined like: FROM node:8.16
and this version includes npm 6.4.1.
I searched and couldn't find a way to tell npm to not try to update when running some script.
Upvotes: 1
Views: 159
Reputation: 59936
The image comes with npm version 6.4.1
and there is no logic in the base image that update NPM itself but it come with 6.4.1
. All you need to downgrade npm version in your Dockerfile.
In the below example the base image has 6.4.1
and the Dockerfile will downgrade the version to [email protected]
. Replace the version the one you required.
FROM node:8.16
COPY . /
RUN npm install -g [email protected]
CMD ["npm", "run", "start"]
Run the command in the container and check the version of NPM using npm -v
you should see 3.10.10
docker exec mynode bash -c "npm -v"
Upvotes: 1