Ubuntu20 installation nodejs error: The following signature cannot be verified because there is no public key

Time:2022-10-17

The node in ubuntu20 is too old, it is 14

I want to install a 16

Just found a tutorial and used the following command:

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

Thensudo apt update, but encountered the following error:

╰─➤  sudo apt update                        
Hits: 1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease      
Hit: 2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Hits: 3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Hit: 4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease          
Get: 5 https://deb.nodesource.com/node_16.x focal InRelease [4,583 B]                
Error: 5 https://deb.nodesource.com/node_16.x focal InRelease
  The following signature could not be verified because there is no public key: NO_PUBKEY 1655A0AB68576280
Reading package list... done
W: GPG 错误:https://deb.nodesource.com/node_16.x focal InRelease: The following signature could not be verified because there is no public key: NO_PUBKEY 1655A0AB68576280
E: The repository "https://deb.nodesource.com/node_16.x focal InRelease" has no digital signature.
N: This source cannot be safely updated with, so this source is disabled by default.
N: See the apt-secure(8) manual for details on repository creation and user configuration.

Then how do I solve it?

Actually, one less-

sudo rm sources.list.d/nodesource.listdelete wrong results

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
Hits: 1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
Hit: 2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Hits: 3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Hit: 4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
Reading package list... done

## 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
Hits: 1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
Hit: 2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Hits: 3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Hit: 4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
Get: 5 https://deb.nodesource.com/node_16.x focal InRelease [4,583 B]   
Get: 6 https://deb.nodesource.com/node_16.x focal/main amd64 Packages [774 B]
5,357 B downloaded, took 7 seconds (744 B/s)
Reading package list... done

## 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

Recommended Today

Doubts about memory leaks in Lua code

1) Doubts about memory leaks in Lua code​2) A leak problem caused by repeated loading of Lua3) Doubts about counting in Addressable4) Merge Mesh plug-in recommendation This is the push of the 265th UWA technical knowledge sharing. Today we continue to select a number of issues related to development and optimization for you. It is […]