我曾经在基于Debian的容器上使用Dockerfile中的以下内容安装NodeJS:

RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - 
RUN apt-get install nodejs -y 

但我最近开始收到以下信息:

    => [base 3/7] RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
                               SCRIPT DEPRECATION WARNING
    ================================================================================ 
TO AVOID THIS WAIT MIGRATE THE SCRIPT Continuing in 60 seconds (press Ctrl-C to abort) ...

我该怎么修好它?如何正确安装NodeJS?

推荐答案

来自script号公路的通知是

  This script, located at https://deb.nodesource.com/setup_X, used to
  install Node.js is deprecated now and will eventually be made inactive.

  Please visit the NodeSource distributions Github and follow the
  instructions to migrate your repo.
  https://github.com/nodesource/distributions 

  The NodeSource Node.js Linux distributions GitHub repository contains
  information about which versions of Node.js and which Linux distributions
  are supported and how to install it.
  https://github.com/nodesource/distributions

instructions on github加到DockerFileRUN

RUN set -uex; \
    apt-get update; \
    apt-get install -y ca-certificates curl gnupg; \
    mkdir -p /etc/apt/keyrings; \
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
     | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
    NODE_MAJOR=18; \
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
     > /etc/apt/sources.list.d/nodesource.list; \
    apt-get update; \
    apt-get install nodejs -y;

Node.js相关问答推荐

如何使用MongoDB在Node.js 中向数组中添加项?

如何在不丢失其他键的情况下解开子文档数组,然后反转该过程?

请求正文未定义

谷歌应用程序脚本UrlFetchApp和nodejs-axios返回不同的结果;MyFitnessPal日记

验证器功能在mongoose 中不起作用

表达 js 错误处理程序在第一个之后被忽略

express app.post的多个参数在Node.js中的定义是什么

我正在try 在公共目录中使用 Express.js 项目部署 Angular 静态构建

为什么我不能将 id 发送到后端并通过 findByIdAndRemove() 删除项目?

在将用作 nodejs/expressjs 中的中间件的函数中使用 keycloak.protect()

更新文档数组中的文档 Mongoose

使用Typescript 时我应该避免循环导入吗?

使用 .pipe(res) 向客户端发送音频不允许您搜索?

GridFS 大文件下载使 Node.js 服务器崩溃. MongoServerError:排序超出了字节的内存限制

自定义 Docker 容器 Github 操作无法在 /github/workspace 中找到 Node 脚本

Aptana Studio 是否有 NodeJS 插件?

我可以通过 JNI 从 Node.js 调用 Java 吗?如何?

使用 MongoDB 更新嵌套数组

node --experimental-modules,请求的模块不提供名为的导出

AWS Lambda:如何将秘密存储到外部 API?