0

I am building a react app with docker but getting error at RUN npm install. I have added ENV PATH and ENV CI, but the problem is not solved yet.

Here is my docker file:

FROM node:alpine

ENV PATH /app/node_modules/.bin:$PATH
ENV CI=true

WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
RUN npm install
COPY ./ ./

CMD ["npm", "start"]

Docker command: docker build -t dockeruser/client .

Terminal respond:

[+] Building 213.3s (9/10)
 => [internal] load build definition from Dockerfile                                                                                                         0.0s 
 => => transferring dockerfile: 225B                                                                                                                         0.0s 
 => [internal] load .dockerignore                                                                                                                            0.0s 
 => => transferring context: 34B                                                                                                                             0.0s 
 => [internal] load metadata for docker.io/library/node:alpine                                                                                               0.0s 
 => [1/6] FROM docker.io/library/node:alpine                                                                                                                 0.0s 
 => [internal] load build context                                                                                                                            0.0s 
 => => transferring context: 957B                                                                                                                            0.0s 
 => CACHED [2/6] WORKDIR /app                                                                                                                                0.0s 
 => CACHED [3/6] COPY package.json ./                                                                                                                        0.0s 
 => CACHED [4/6] COPY package-lock.json ./                                                                                                                   0.0s 
 => ERROR [5/6] RUN npm install                                                                                                                            213.2s 
------
 > [5/6] RUN npm install:
#9 213.1 npm ERR! code ECONNRESET
#9 213.1 npm ERR! network aborted
#9 213.1 npm ERR! network This is a problem related to network connectivity.
#9 213.1 npm ERR! network In most cases you are behind a proxy or have bad network settings.
#9 213.1 npm ERR! network
#9 213.1 npm ERR! network If you are behind a proxy, please make sure that the
#9 213.1 npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
#9 213.1
#9 213.1 npm ERR! A complete log of this run can be found in:
#9 213.1 npm ERR!     /root/.npm/_logs/2021-07-07T07_40_20_529Z-debug.log
------
executor failed running [/bin/sh -c npm install]: exit code: 1
2
  • Can you try running these npm config set proxy http://10.50.225.222:3128 npm config set https-proxy http://10.50.225.222:3128 Of course you have to change the address and ports Commented Jul 7, 2021 at 13:10
  • Or can you run npm config list to see if there is any proxy setting? Commented Jul 7, 2021 at 13:13

2 Answers 2

1

I had the exactly same issue. What I did is increased the timeout
npm install --fetch-timeout=600000 and it worked.

Sign up to request clarification or add additional context in comments.

Comments

0

Obviously, you are not having bad network, but the application is behind a proxy as can be seen in the error log. There are two potential fixes that I can think of.

Firstly, you can set up proxy configuration with

npm config set proxy http://proxy_host:port
npm config set https-proxy https://proxy.company.com:8080

Or secondly, you can clear your proxy with

npm config rm proxy
npm config rm https-proxy

set HTTP_PROXY=null
set HTTPS_PROXY=null

Then you can run

npm config list

to see if there is any proxy config left.

Of course, I assume that you know what your proxy address is.

4 Comments

Yes, I have checked my pc's settings where proxy is not set indeed.
I'm still stuck at the same error! Can you suggest any specific solution to solve the npm install error?
have you tried running the above command in dockerfile?
Yes. It shows the same error at the same point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.