npm WARN old lockfile package-lock.json 文件是使用旧版本的 npm 创建的 [英] npm WARN old lockfile The package-lock.json file was created with an old version of npm

查看:5469
本文介绍了npm WARN old lockfile package-lock.json 文件是使用旧版本的 npm 创建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下的 dockerfile,但是在 RUN npm ci 步骤中,有一个警告 npm WARN old lockfile The package-lock.json 文件是用旧版本的 npm 创建的 我想不通..

I've a dockerfile as below but during RUN npm ci step, there is a warning npm WARN old lockfile The package-lock.json file was created with an old version of npm which i can not able to figure out..

我尝试使用 npm install 而不是 npm ci,添加了 --package-lock 标志,但仍然收到此警告.这是一种警告,我必须忽略还是应该解决这个问题

I tried with npm install rather npm ci, added --package-lock flag but still getting this warning. Its a kind of warning do I have to ignore or what should I to solve this

Step 12/26 : RUN npm ci --production --package-lock &&     npm ci --production --package-lock --prefix ./ui-runner
 ---> Running in 3473c209b98c
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 

这里是 Dockerfile.

Here is Dockerfile.

FROM node:14.17.1-alpine3.13 AS builder
WORKDIR /usr/src/app
COPY package.json package-lock.json* ./
COPY ui-runner/package*.json ./ui-runner/
COPY .npmrc .npmrc
COPY ui-runner/.npmrc ./ui-runner/.npmrc
RUN npm -g install npm@7.19.1
RUN npm ci --production --package-lock && 
    npm ci --production --package-lock --prefix ./ui-runner
RUN rm -f .npmrc && 
    rm -f ui-runner/.npmrc

FROM node:14.17.1-alpine3.13
WORKDIR /usr/src/app
RUN apk update && apk add --no-cache curl bash
RUN addgroup -g 1001 test && 
    adduser -S -u 1001 -G test test
RUN chown -R test /usr/src/app && 
    chmod 755 /usr/src/app
COPY --from=builder /usr/src/app /usr/src/app
COPY . .
RUN npm run build:docker
USER test
EXPOSE 3000 9183
CMD [ "npm", "run", "start:ui-runner" ]

推荐答案

有几种方法可以解决这个问题:

There are several ways to deal with this:

  1. 忽略它.只是一个警告,不影响模块的安装.

  1. Ignore it. It's just a warning and does not affect the installation of modules.

运行 npm ci 确保您的 node_modules 反映锁定文件,然后删除 package-lock.json,然后运行 ​​npm install(使用较新版本npm) 来重新生成一个 package-lock.json.因为 node_modules 中的所有内容都将满足所有要求,所以 npm install 的唯一变化将是新生成的 package-lock.json 文件.将 package-lock.json 的更新版本提交到 repo/Docker 映像或其他任何内容.

Run npm ci to make sure your node_modules reflects the lock file, then remove package-lock.json, and then run npm install (with the newer version of npm) to regenerate a package-lock.json. Because everything in node_modules will meet all the requirements, the only change from npm install will be a newly-generated package-lock.json file. Commit the updated version of package-lock.json to the repo/Docker image or whatever.

npm 降级到生产中的旧版本.考虑运行 npm 版本 6,因为这是当前(在撰写本文时)长期支持 (LTS) 版本的 Node.js 附带的.在这个问题中被问到的情况下,我想你可以从 Dockerfile 中省略 RUN npm -g install npm@7.19.1 而使用 npm 的版本随 Docker 映像一起安装的 code>(在这种情况下几乎可以肯定是 npm@6,因为这是 Node.js 14.x 附带的).

Downgrade npm to an older version in production. Consider running npm version 6 as that is what ships with the current (as of this writing) Long Term Support (LTS) version of Node.js. In the case being asked about in this question, I imagine you can just leave out the RUN npm -g install npm@7.19.1 from the Dockerfile and instead use the version of npm that is installed with the Docker image (which in this case will almost certainly be npm@6 since that is what ships with Node.js 14.x).

如果你已经安装了一个版本的 npm,但是想用旧版本的 npm 运行一个命令,但要保留新版本,你可以使用 npx(随 npm 提供)来做到这一点.使用 -p 标志指定您想要的 npm 版本.例如,即使您安装了版本 7,npx -p npm@6 npm ci 也会使用 npm 版本 6 运行 npm ci.p>

If you already have a version of npm installed but want to run one command with an older version of npm but otherwise keep the newer version, you can use npx (which ships with npm) to do that. Use the -p flag to specify the version of npm you want. For example, npx -p npm@6 npm ci would run npm ci with npm version 6 even if you have version 7 installed.

这篇关于npm WARN old lockfile package-lock.json 文件是使用旧版本的 npm 创建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆