Docker 构建:npm WARN EBADENGINE 不支持的引擎

问题描述 投票:0回答:1

我正在基于

mcr.microsoft.com/devcontainers/python:0-3.11-bullseye
构建图像 我的 docker 文件末尾有以下内容:

RUN apt-get update && apt-get install -y nodejs npm
RUN npm install npm@latest -g && \
    npm install n -g && \
    n latest
#RUN npm install -g typescript

RUN node --version
RUN npm --version

我在构建结束时看到了这一点:

#13 [ 9/12] RUN apt-get update && apt-get install -y nodejs npm
#13 CACHED

#14 [10/12] RUN npm install npm@latest -g &&     npm install n -g &&     n latest
#14 0.793 npm WARN EBADENGINE Unsupported engine {
#14 0.793 npm WARN EBADENGINE   package: '[email protected]',
#14 0.794 npm WARN EBADENGINE   required: { node: '^18.17.0 || >=20.5.0' },
#14 0.795 npm WARN EBADENGINE   current: { node: 'v12.22.12', npm: '7.5.2' }
#14 0.796 npm WARN EBADENGINE }
#14 2.626
#14 2.626 added 1 package, and audited 209 packages in 2s
#14 2.626
#14 2.626 24 packages are looking for funding
#14 2.626   run `npm fund` for details
#14 2.627
#14 2.627 found 0 vulnerabilities
#14 3.639
#14 3.639 added 1 package, and audited 2 packages in 890ms
#14 3.640
#14 3.640 found 0 vulnerabilities
#14 3.813   installing : node-v22.1.0
#14 3.898        mkdir : /usr/local/n/versions/node/22.1.0
#14 3.901        fetch : https://nodejs.org/dist/v22.1.0/node-v22.1.0-linux-x64.tar.xz
#14 7.582      copying : node/22.1.0
#14 8.766    installed : v22.1.0 (with npm 10.7.0)
#14 8.766
#14 8.766 Note: the node command changed location and the old location may be remembered in your current shell.
#14 8.766          old : /usr/bin/node
#14 8.766          new : /usr/local/bin/node
#14 8.766 If "node --version" shows the old version then start a new shell, or reset the location hash with:
#14 8.766 hash -r  (for bash, zsh, ash, dash, and ksh)
#14 8.766 rehash   (for csh and tcsh)
#14 DONE 8.9s

#15 [11/12] RUN node --version
#15 0.399 v22.1.0
#15 DONE 0.4s

#16 [12/12] RUN npm --version
#16 0.712 10.7.0
#16 DONE 0.7s

我不清楚如何解决这个问题,或者这是否是一个问题,因为看起来确实安装了较新的版本。

我看过几篇关于如何安装 npm/node 的 stackoverflow 帖子,尝试过其中很多,但我似乎无法摆脱那些警告行。 这是值得关心的事情吗?如果是这样,解决这个问题的正确方法是什么

编辑:发布此内容后,我注意到在初次安装 Nodejs 和 npm 后出现了

CACHED
行。使用
--no-cache
选项构建似乎没有帮助

node.js typescript npm
1个回答
0
投票

以下内容将绕过图像被及时冻结所暗示的过时节点版本,因此不要回退到发行版的旧版本节点,而是运行此...

curl -fsSL https://deb.nodesource.com/setup_22.x | bash - &&\
apt-get install -y nodejs

了解更多有关您的选项的信息,请访问 https://github.com/nodesource/distributions?tab=readme-ov-file#debian-versions

在安装命令之后运行的命令应该使用现代节点。我不会在任何时候安装 Node 的发行版 - 它的主要工作是拥有 MS 工具和正确的 python。

© www.soinside.com 2019 - 2024. All rights reserved.