Edited at

npm install very slow in container

More than 3 years have passed since last update.

Doing npm install on a container when building image is notoriously slow. It should be slow because it's on a virtual machine (I was using boot2docker), but it's like heaven and earth when compared to npm install on host machine. Try using npm install --verbose, on host machine you won't be able to read the log because it scrolls so fast. While on a container, you can see it's stopping every now and then -- especially when creating a .cache.json file.

Try this before npm install:


npm config set registry http://registry.npmjs.org/


eg:

# Dockerfile

RUN npm config set registry http://registry.npmjs.org/ && npm install --no-optional --verbose

It works magic for me! :shipit: