'npm install issues inside a container
I am trying to run npm install inside a container that starting FROM node:17.5-bullseye-slim. I can run npm install on the host without problems but it fails in the container. My Dockerfile looks like:
FROM node:17.5-bullseye-slim
ENV TZ=America/Chicago
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /usr/src/[directory_name]
COPY package*.json ./
RUN apt-get update; \
apt-get install -y python3; \
apt-get install -y python2 make; \
apt-get install -y g++; \
ln -s /usr/bin/python2.7 /usr/bin/python; \
npm install
COPY . .
This is the error that comes out of the process:
npm notice
npm notice New minor version of npm available! 8.4.1 -> 8.5.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.5.1>
npm notice Run `npm install -g [email protected]` to update!
npm notice
npm ERR! code 1
npm ERR! path /usr/src/poolapi/node_modules/epoll
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | arm
npm ERR! gyp http GET https://nodejs.org/download/release/v17.5.0/node-v17.5.0-headers.tar.gz
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: getaddrinfo EAI_AGAIN nodejs.org
npm ERR! gyp ERR! stack at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:72:26)
npm ERR! gyp ERR! System Linux 5.10.63-v7+
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/src/poolapi/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /usr/src/poolapi/node_modules/epoll
npm ERR! gyp ERR! node -v v17.5.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
Solution 1:[1]
It helped for me:
FROM node:16-bullseye
RUN apt-get update && apt-get install build-essential -y
It option also worked:
FROM node:16-bullseye-slim
RUN apt-get update; \
apt-get install -y python3; \
apt-get install -y python2 make; \
apt-get install -y g++; \
ln -s /usr/bin/python2.7 /usr/bin/python;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
