How to use node from docker to install packages locally?

Viewed 47

So I want to install packages locally using npm from docker but how do I specify the image?

I tried doing following:

docker run --rm -v $(pwd):/app npm install
1 Answers

If I understand you correctly, you can use the node image. The node image usually runs in the root directory, so you need to change into the /app directory first. Something like this

docker run --rm -v $(pwd):/app node /bin/bash -c "cd /app && npm install"
Related