代码之家  ›  专栏  ›  技术社区  ›  The Fool

dockerfile中的npm ci在使用节点16作为基本映像时抛出401未授权

  •  1
  • The Fool  · 技术社区  · 5 年前

    出于某种原因, NPM 运行时需要身份验证 npm ci 以码头工人的身材。我以前从未遇到过这个问题。发生了什么事?

    这是我的Dockerfile:

    FROM node:16 as builder
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci
    

    这是我收到的错误:

     > [4/4] RUN npm ci:
    #8 1.357 npm notice 
    #8 1.357 npm notice New minor version of npm available! 7.21.1 -> 7.23.0
    #8 1.357 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.23.0>
    #8 1.357 npm notice Run `npm install -g npm@7.23.0` to update!
    #8 1.357 npm notice 
    #8 1.358 npm ERR! code E401
    #8 1.359 npm ERR! Unable to authenticate, your authentication token seems to be invalid.
    #8 1.359 npm ERR! To correct this please trying logging in again with:
    #8 1.359 npm ERR!     npm login
    #8 1.370 
    #8 1.370 npm ERR! A complete log of this run can be found in:
    #8 1.370 npm ERR!     /root/.npm/_logs/2021-09-11T11_55_11_040Z-debug.log
    

    这是我的包裹。json:

    {
      "name": "warranty-ui",
      "version": "0.0.0",
      "type": "module",
      "scripts": {
        "dev": "vite",
        "build": "vite build",
        "serve": "vite preview"
      },
      "devDependencies": {
        "@sveltejs/vite-plugin-svelte": "^1.0.0-next.11",
        "sass": "^1.39.2",
        "svelte": "^3.37.0",
        "vite": "^2.5.4"
      },
      "dependencies": {
        "bulma": "^0.9.3",
        "i18next": "^20.6.1",
        "msal": "^1.4.12"
      }
    }
    

    编辑:我在使用 node:14 作为基础图像。错误没有出现。

    FROM node:14 as builder
    

    这对我有效,但可能不是每个人都有效。

    0 回复  |  直到 5 年前