The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Hangs Docker build due to syntax error
What I Wanted to Do
npm install when building a Docker image
What Happened Instead
Had a syntax error in the Dockerfile and
npm hanged and brought everything to a halt. I would have expected
npm to exit with an error code.
I had something like this in my
FROM node:11.13.0-alpine RUN npm install --global foo \ COPY . /foo/bar
This is a syntax error due to the backslash at the end of the first line. This is what I see when I run
npm ERR! code ENOLOCAL npm ERR! Could not install from "" as it does not contain a package.json file.
and everything hangs right there. I would have expected an error exit, not hanging.
I saw the error message but not the hang when I tried reproducing using the Dockerfile steps you listed, finished almost immediately. What was the next command in your file?
$ docker build . Sending build context to Docker daemon 2.048kB Step 1/2 : FROM node:11.13.0-alpine ---> 953c516e1466 Step 2/2 : RUN npm install --global foo COPY . /foo/bar ---> Running in c59a1d6930f3 npm ERR! code ENOLOCAL npm ERR! Could not install from "" as it does not contain a package.json file. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2019-04-03T07_40_38_487Z-debug.log The command '/bin/sh -c npm install --global foo COPY . /foo/bar' returned a non-zero code: 1
When I do
docker build as you do, I get the same result as you. I exits immediately.
When I do
docker-compose build is when it hangs