ubuntu20安装nodejs报错:由于没有公钥,无法验证下列签名

在 ubuntu20 中的 node 太 old 了,是 14

我想安装一个 16

就找了一个教程, 使用了下面的命令:

curl -s https://deb.nodesource.com/setup_16.x | sudo bash              

然后 sudo apt update, 但是遇到了下面的报错:

╰─➤  sudo apt update                        
命中:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease      
命中:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
命中:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
命中:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease          
获取:5 https://deb.nodesource.com/node_16.x focal InRelease [4,583 B]                
错误:5 https://deb.nodesource.com/node_16.x focal InRelease
  由于没有公钥,无法验证下列签名: NO_PUBKEY 1655A0AB68576280
正在读取软件包列表... 完成
W: GPG 错误:https://deb.nodesource.com/node_16.x focal InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY 1655A0AB68576280
E: 仓库 “https://deb.nodesource.com/node_16.x focal InRelease” 没有数字签名。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。             

然后我是怎么解决的?

其实就是少打了一个 -

sudo rm sources.list.d/nodesource.list 删掉错误的结果

错误的命令:curl -s https://deb.nodesource.com/setup_16.x | sudo bash

正确的命令:curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -

结果如下:

─➤  curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -                                                              1 ↵

## Installing the NodeSource Node.js 16.x repo...


## Populating apt-get cache...

+ apt-get update
命中:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
命中:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
命中:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
命中:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
正在读取软件包列表... 完成

## Confirming "focal" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_16.x/dists/focal/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null

## Creating apt sources list file for the NodeSource Node.js 16.x repo...

+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
命中:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
命中:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
命中:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
命中:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
获取:5 https://deb.nodesource.com/node_16.x focal InRelease [4,583 B]   
获取:6 https://deb.nodesource.com/node_16.x focal/main amd64 Packages [774 B]
已下载 5,357 B,耗时 7秒 (744 B/s)
正在读取软件包列表... 完成

## Run `sudo apt-get install -y nodejs` to install Node.js 16.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

你可能感兴趣的:(ubuntu20安装nodejs报错:由于没有公钥,无法验证下列签名)