Avi*_*Avi 7 linux ubuntu node.js npm docker
我有一个安装了nodejs 和npm 的docker。以前它工作得很好,但从今天开始,它开始崩溃并出现以下错误。
\n------\n > [assets 4/9] RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs && npm i npm@latest -g:\n#8 67.38 Setting up nodejs (16.20.2-deb-1nodesource1) ...\n#8 67.82 npm ERR! code EBADENGINE\n#8 67.82 npm ERR! engine Unsupported engine\n#8 67.82 npm ERR! engine Not compatible with your version of node/npm: npm@10.0.0\n#8 67.82 npm ERR! notsup Not compatible with your version of node/npm: npm@10.0.0\n#8 67.82 npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"}\n#8 67.82 npm ERR! notsup Actual: {"npm":"8.19.4","node":"v16.20.2"} \n#8 67.82 npm ERR! A complete log of this run can be found in:\n#8 67.82 npm ERR! /root/.npm/_logs/2023-09-01T07_07_39_330Z-debug-0.log\n------\nRun Code Online (Sandbox Code Playgroud)\nDocker 文件。
\nFROM ubuntu:18.04\n\nENV TMPDIR=/tmp\n\nRUN apt-get update -y \\\n && apt-get upgrade -y \\\n && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \\\n curl \\\n software-properties-common \\\n bzip2 \\\n git\n\nRUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \\\n firefox \\\n chromium-browser\n\n# Install Node\nRUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \\\n && apt-get install -y \\\n nodejs \\\n && npm i npm@latest -g\n\nENV CHROMIUM_BIN=/usr/bin/chromium-browser\n\nRUN rm -rf /app/*\n\nCOPY ./code/ /app/\nWORKDIR /app\n\nRUN rm -rf node_modules \\\n && rm -rf ./static/vendor\n\nRUN npm ci --legacy-peer-deps\nRun Code Online (Sandbox Code Playgroud)\n我还看到一些与安装 nodejs 命令相关的警告。
\n#0 0.297 ================================================================================\n#0 0.297 \xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\n#0 0.297 ================================================================================\n#0 0.297 \n#0 0.297 SCRIPT DEPRECATION WARNING \n#0 0.297 \n#0 0.297 \n#0 0.297 This script, located at https://deb.nodesource.com/setup_X, used to\n#0 0.297 install Node.js is deprecated now and will eventually be made inactive.\n#0 0.297 \n#0 0.297 Please visit the NodeSource distributions Github and follow the\n#0 0.297 instructions to migrate your repo.\n#0 0.297 https://github.com/nodesource/distributions\n#0 0.297 \n#0 0.297 The NodeSource Node.js Linux distributions GitHub repository contains\n#0 0.297 information about which versions of Node.js and which Linux distributions\n#0 0.297 are supported and how to install it.\n#0 0.297 https://github.com/nodesource/distributions\n#0 0.297 \n#0 0.297 \n#0 0.297 SCRIPT DEPRECATION WARNING\n#0 0.297 \n#0 0.297 ================================================================================\n#0 0.297 \xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\xe2\x96\x93\n#0 0.297 ================================================================================\nRun Code Online (Sandbox Code Playgroud)\n那么用 docker 安装 Nodejs 的其他最佳方法是什么?
\nGok*_*dir 11
这似乎是由 npm 10 版本引起的
https://github.com/npm/cli/releases/tag/v10.0.0
对节点 14 和 16 的支持已被删除。npm 现在支持节点 ^18.17.0 || >=20.5.0
尝试在 Dockerfile 中安装 npm 9:
npm i npm@9 -g
Run Code Online (Sandbox Code Playgroud)
小智 1
我们可以使用创建的图像,而不是从头开始构建它。
FROM node:lts
RUN rm -rf /app/*
COPY ./code/ /app/
WORKDIR /app
RUN rm -rf node_modules \
&& rm -rf ./static/vendor
RUN npm ci --legacy-peer-deps
Run Code Online (Sandbox Code Playgroud)
请参考https://nodejs.org/en/docs/guides/nodejs-docker-webapp
| 归档时间: |
|
| 查看次数: |
7405 次 |
| 最近记录: |