I'm using Docker version 20.10.20
and npm 8.5.2
(that's important because I had to use --omit=dev
instead of --only=production
).
I'm trying to build a Node.JS version 16.14
app following a tutorial, but the file doesn't seem to work. It gives me this error:
executor failed running [/bin/sh -c npm install --prefix client --omit=dev]: exit code: 254
This is generated from the part:
RUN npm run install-client --omit=dev
This is the docker file:
FROM node:16.14-alpine
WORKDIR /app
COPY package*.json ./
COPY client/package*.json client/
RUN npm run install-client --omit=dev
COPY server/package*.json server/
RUN npm run install-server --omit=dev
COPY client/ client/
RUN npm run build --prefix client
COPY server/ server/
USER node
CMD ["npm", "start", "--prefix", "server"]
EXPOSE 8000
And these are the scripts i'm using in the package.json
"scripts": {
"install-client": "npm install --prefix client",
"install-server": "npm install --prefix server",
"build": "npm run build --prefix client && npm start --prefix server",
"docker-build": "docker build . -t alesssz/nasa-project"
}
Any suggestion?
EDIT:
I changed FROM node:16.14-alpine
to FROM node:16-alpine
and that error doesn't appear anymore. The problem is that the same command (RUN npm run install-client --omit=dev
) now lasts forever. I even tried to add --verbose
to see what's going on:
[ 5/10] RUN npm run install-client --omit=dev 59.7s
=> => # npm timing metavuln:cache:get:security-advisory:react-scripts:jzAvVcibtp6793goF6bMS+3REmxevJ33fk+CUpasW439H9DWo8HZryeL2vn3uGr5kT2MYZIC9lZQ2/rASfNe7w== Completed in 0ms
=> => # npm timing metavuln:load:security-advisory:react-scripts:6kGFeBaa+c/FiSh7gkidT8uneFtpq6JLmia0+ROmr6BVMW4bnUZ9bZd/dO+Squ13eCU8+LJ9HJjq2v7UKojEPA== Completed in 7ms
=> => # npm timing metavuln:cache:put:security-advisory:react-scripts:jzAvVcibtp6793goF6bMS+3REmxevJ33fk+CUpasW439H9DWo8HZryeL2vn3uGr5kT2MYZIC9lZQ2/rASfNe7w== Completed in 5ms
=> => # npm timing metavuln:calculate:security-advisory:react-scripts:6kGFeBaa+c/FiSh7gkidT8uneFtpq6JLmia0+ROmr6BVMW4bnUZ9bZd/dO+Squ13eCU8+LJ9HJjq2v7UKojEPA== Completed in 13ms
=> => # npm timing auditReport:init Completed in 19965ms
=> => # npm timing reify:audit Completed in 22816ms
It's getting stuck there forever, it doesn't go further.
EDIT (following @JeffRSon comment):
I tried to use RUN ping registry.npmjs.org
just before RUN npm run install-client --omit=dev
and it seems it runs forever too (I stopped it after 17 minutes):
=> [ 6/12] RUN ping registry.npmjs.org
=> => # 64 bytes from 104.16.26.35: seq=1040 ttl=37 time=21.784 ms
=> => # 64 bytes from 104.16.26.35: seq=1041 ttl=37 time=25.782 ms
=> => # 64 bytes from 104.16.26.35: seq=1042 ttl=37 time=21.641 ms
=> => # 64 bytes from 104.16.26.35: seq=1043 ttl=37 time=24.249 ms
=> => # 64 bytes from 104.16.26.35: seq=1044 ttl=37 time=21.049 ms
=> => # 64 bytes from 104.16.26.35: seq=1045 ttl=37 time=19.880 ms
I then tried docker run -it --rm node:16-alpine sh
and it downloads that image in my Docker Desktop and it open the command prompt for it
docker run -it --rm node:16-alpine sh
Unable to find image 'node:16-alpine' locally
16-alpine: Pulling from library/node
213ec9aee27d: Already exists
90d4f1a52341: Already exists
96f9ff3b94d8: Already exists
f05a94b04b95: Already exists
Digest: sha256:2175727cef5cad4020cb77c8c101d56ed41d44fbe9b1157c54f820e3d345eab1
Status: Downloaded newer image for node:16-alpine
/ #
It still run forerev thought...any other suggestion?