"npm ci" error while "docker compose build --no-cache" processing

Hi.
There is host OS windows 10 hyper-v and guest OS Ubuntu 20.04. On Ubuntu has installed docker engine Version:28.3.2.
There is a complex docker configuration. If build it via “docker compose build --no-cache”, then processing dockerfile

FROM node:20.11.0
ARG ENV_FILE
WORKDIR /app
ADD package.json /app/package.json
ADD package-lock.json /app/package-lock.json
COPY ${ENV_FILE} /app/deploy.env
RUN echo "token :$GITLAB_DEPLOY_TOKEN"

RUN export $(grep -v '^#' /app/deploy.env | xargs) && npm config set -- "//<site name>/api/v4/projects/58/packages/npm/:_authToken=${GITLAB_DEPLOY_TOKEN}"
RUN npm ci --cache .npm --prefer-offline

produce errors:

=> ERROR [client  8/10] RUN npm ci --cache .npm --prefer-offline                                                                                                                                     13.6s
------                                                                                                                                                                                                       > [client  8/10] RUN npm ci --cache .npm --prefer-offline:                                                                                                                                                 
13.11 npm notice                                                                                                                                                                                            
13.11 npm notice New major version of npm available! 10.2.4 -> 11.4.2                                                                                                                                       
13.11 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v11.4.2>                                                                                                                               
13.11 npm notice Run `npm install -g npm@11.4.2` to update!                                                                                                                                                 
13.11 npm notice                                                                                                                                                                                            
13.11 npm ERR! code ECONNRESET                                                                                                                                                                              
13.11 npm ERR! syscall read                                                                                                                                                                                 
13.11 npm ERR! errno -104                                                                                                                                                                                   
13.11 npm ERR! network read ECONNRESET                                                                                                                                                                      
13.11 npm ERR! network This is a problem related to network connectivity.                                                                                                                                   
13.11 npm ERR! network In most cases you are behind a proxy or have bad network settings.                                                                                                                   
13.11 npm ERR! network                                                                                                                                                                                      
13.11 npm ERR! network If you are behind a proxy, please make sure that the                                                                                                                                 
13.11 npm ERR! network 'proxy' config is set properly.  See: 'npm help config'                                                                                                                              
13.13 
13.13 npm ERR! A complete log of this run can be found in: /app/.npm/_logs/2025-07-18T12_56_35_177Z-debug-0.log

This looks like you have restricted network connectivity (as in requires a http proxy to be configured), or the way you configure the auth token is wrong.

The first one is easy to test: just add a RUN apt update somewhere in your Dockerfile (of course in a line before the line that throws the error).

RUN apt update works successfully

Then it could be an npm config somewhere. I read that npm config files can contain proxy settings that people forgot about.

I would also check if the URL set in the second to last step is correct. Or if you need any variable set in that step later as nothing will be available in the npm cli layer that you export in the previous layer.