How should I handle node image errors?

My project env is Vue3.4.21+TS+Vite5.1.5
This is my Dockerfile

FROM node:20.8.1 as build-stage

WORKDIR /app

COPY package*.json ./

RUN npm cache clean --force

RUN npm config set registry https://registry.npmjs.org/

RUN npm install

COPY . .

RUN npm run build

FROM nginx:1.21.3

COPY --from=build-stage /app/dist/ /usr/share/nginx/myapp

COPY nginx/default.conf /etc/nginx/conf.d/default.conf

EXPOSE 8310

CMD ["nginx", "-g", "daemon off;"]

This is my docker-compose.yml file

version: "3.4"

services:
  myapp:
    image: myapp
    build:
      context: .
      dockerfile: ./Dockerfile
    environment:
      NODE_ENV: production
    ports:
      - 8310:8310
    restart: unless-stopped

When I run the docker-compose up -d command, an error will be reported during the npm install stage.

15.96 npm ERR! code E401
15.96 npm ERR! Incorrect or missing password.
15.96 npm ERR! If you were trying to login, change your password, create an
15.96 npm ERR! authentication token or enable two-factor authentication then
15.96 npm ERR! that means you likely typed your password in incorrectly.
15.96 npm ERR! Please try again, or recover your password at:
15.96 npm ERR!     https://www.npmjs.com/forgot
15.96 npm ERR!
15.96 npm ERR! If you were doing some other operation then your saved credentials are
15.96 npm ERR! probably out of date. To correct this please try logging in again with:
15.96 npm ERR!     npm login
15.96
15.96 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-04-23T13_29_24_341Z-debug-0.log
------
failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1

My project package.json file.

{
  "name": "vite-project",
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "dev:stable": "cross-env VITE_STABLE=true vite --port 3005",
    "start:both": "concurrently \"npm run dev\" \"npm run dev:stable\"",
    "build": "vite build",
    "build:mapping": "vite build --mode mapping",
    "build:test": "vite build --mode test",
    "preview": "vite preview"
  },
  "dependencies": {
    "@intlify/vue-i18n-loader": "^4.2.0",
    "@vueuse/core": "^10.9.0",
    "ant-design-vue": "^4.1.2",
    "axios": "^1.6.7",
    "crypto-js": "^4.2.0",
    "dayjs": "^1.11.10",
    "echarts": "^5.5.0",
    "echarts-liquidfill": "^3.1.0",
    "element-plus": "^2.7.1",
    "eslint-plugin-prettier": "^5.1.3",
    "highlight.js": "^11.9.0",
    "html2canvas": "^1.4.1",
    "html2pdf.js": "^0.10.1",
    "js-sha256": "^0.11.0",
    "jspdf": "^2.5.1",
    "nprogress": "^0.2.0",
    "pinia": "^2.1.7",
    "pinia-plugin-persistedstate": "^3.2.1",
    "prettier": "^3.2.5",
    "process": "^0.11.10",
    "qs": "^6.11.2",
    "terser": "^5.28.1",
    "uuid": "^9.0.1",
    "vue": "^3.4.21",
    "vue-clipboard3": "^2.0.0",
    "vue-dompurify-html": "^5.0.1",
    "vue-i18n": "^9.9.0",
    "vue-router": "^4.3.0"
  },
  "devDependencies": {
    "@types/crypto-js": "^4.2.2",
    "@types/node": "^20.11.24",
    "@types/nprogress": "^0.2.3",
    "@types/qs": "^6.9.12",
    "@types/tinycolor2": "^1.4.6",
    "@types/uuid": "^9.0.8",
    "@typescript-eslint/eslint-plugin": "^7.1.1",
    "@typescript-eslint/parser": "^7.1.1",
    "@vitejs/plugin-vue": "^5.0.4",
    "concurrently": "^8.2.2",
    "cross-env": "^7.0.3",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-config-standard": "^17.1.0",
    "eslint-define-config": "^2.1.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-vue": "^9.22.0",
    "less": "^4.2.0",
    "path": "^0.12.7",
    "typescript": "^5.3.3",
    "unplugin-vue-components": "^0.26.0",
    "vite": "^5.1.5",
    "vite-plugin-eslint": "^1.8.1",
    "vue-eslint-parser": "^9.4.2",
    "vue-tsc": "^2.0.4"
  }
}

There is no problem with my local installation and building. When use the Docker Desktop and running docker-compose up -d command, an error message appears in the npm install step.

Hello

So far I understand nothing to do with docker.

I suppose you are using a private dependencies in your package.json file and, thus, you should provide some credentials to npm.

Hello, I am not using any private npm package