The node in ubuntu20 is too old, it is 14

I want to install a 16

I found a tutorial and used the following command:

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

Then sudo apt update , but encountered the following error:

 ╰─➤  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) 手册以了解仓库创建和用户配置方面的细节。

Then how do I solve it?

In fact, one less call -

sudo rm sources.list.d/nodesource.list delete wrong result

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

Correct command: curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -

The result is as follows:

 ─➤  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

universe_king
3.4k 声望678 粉丝