docker-node
docker-node copied to clipboard
npm install leads to error in latest alpine image
Dockerfile:
FROM node:13.12.0-alpine AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
If I run docker build it always exits with npm ERR! cb() never called!
After chaning the image to 12.16.0-alpine it works. Also not including package-lock.json fixes this problem.
The npm *-debug.log file contains nothing useful:
<-- snip downloading and extracting -->
19581 timing npm Completed in 95032ms
19582 error cb() never called!
19583 error This is an error with npm itself. Please report this error at:
19584 error <https://npm.community>
The JS app I try to dockerize here is a freshly generated Angular app.
This doesn't seem to be an issue with the image but with the install scripts for one of the dependencies failing. Perhaps one of your dependencies relies on node binding that don't support Alpine linux?
But it's supported on the previous version alpine image.
How can I find out which dependency?
Does this error also exist in different variants of 13.12.0 image?
Strangely this issue seems to not occur anymore. I successfully built it with node:13.12.0-alpine, node:13.12.0-slim and node:13.12.0 images with --no-cache and --pull flags.
It may be related to slow network connection. It's failing randomly on my system using node:13.8-alpine. Yesterday everything built, today exactly the same dockerfile fails. When I try to reproduce it manually in the container then first try fails and second or third one succeeds. npm cache clean --force - and it fails again.
And on CI where connection is a bit more stable and faster it seems to never fail with this error.
Edit.
Literally chaining a few npm ci calls makes my dockerfile pass...
RUN npm ci --production || npm ci --production || npm ci --production
But it works exactly the same for node:13.8 so it's rather an npm issue than alpine.