LinuxでNode.JSをインストール/アップグレードしようとしたときに何が間違っていますか?

LinuxでNode.JSをインストール/アップグレードしようとしたときに何が間違っていますか?

オペレーティングシステム:Linux Mint 18.3。 Ubuntuに似ています。

Linuxと同様に、ソフトウェアをインストールする方法がわかりません。

  1. すでにシステムにいますか?この場合はそうです。しかし、古いです:4.2.6。この記事を書いている時点で、現在のLTSバージョンは10.16.3です。
  2. 適切なものを使うべきですか?
  3. ソフトウェアマネージャを使用する必要がありますか?
  4. PPAを使用する必要がありますか?
  5. zipファイルをダウンロードして解凍する必要がありますか?

他のユーザーのソフトウェア管理者のレビューは、「最新バージョンを入手するにはここに移動してください」(https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions)

最初のコマンドは

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

失敗します。

> 
mike@M17A ~ $  curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
[sudo] password for mike: 

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


## Populating apt-get cache...

+ apt-get update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease                        
Hit:3 http://dl.google.com/linux/chrome/deb stable Release                     
Hit:4 http://ppa.launchpad.net/adabbas/1stppa/ubuntu xenial InRelease          
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]       
Get:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]     

... // then many messages like this:

Ign:42 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main all Packages
Ign:43 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main Translation-en_GB
Ign:44 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main Translation-en_GB
Ign:44 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main Translation-en
Fetched 329 kB in 23s (14.0 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repository.spotify.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4773BD5E130D1D45
W: The repository 'https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu serena Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: Failed to fetch http://repository.spotify.com/dists/stable/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4773BD5E130D1D45
E: Failed to fetch https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu/dists/serena/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu/dists/serena/main/binary-amd64/Packages  404  Not Found
W: Some index files failed to download. They have been ignored, or old ones used instead.
Error executing command, exiting

...このすべてのmariadbコマンドが何について何をするのかわかりません。私のシステムにMariaDBがありますが、何かが間違っているのではないかと心配です。

次のコマンドを試してみると、これが失敗したことを示すようです。

mike@M17A ~ $  sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
nodejs is already the newest version (4.2.6~dfsg-1ubuntu4.2).
0 to upgrade, 0 to newly install, 0 to remove and 600 not to upgrade.

...つまり、システムはまだ4.2.6を最新バージョンと考えています。

より一般的に、Linuxに新しいソフトウェアをインストールするためのプロトコルは正確に何ですか?上記の番号リスト(1〜5)が正しいアプローチですか?専門家は、新しいソフトウェアをインストールするときにどの優先順位を使用しますか?

それから試してみました

sudo apt-get update失敗が問題の源であるようです。

他の質問からインスピレーションを受けて、次のことを試しました。

sudo rm /var/lib/apt/lists/* -vf

以下は次のとおりです。

sudo apt-get update

より多くのエラーと警告のリストは私にとって大きな意味はありません。

...
Err:40 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main amd64 Packages
  404  Not Found
Ign:41 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main i386 Packages
Ign:42 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main all Packages
Ign:43 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main Translation-en_GB
Ign:44 https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena/main Translation-en
Fetched 329 kB in 28s (11.6 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repository.spotify.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4773BD5E130D1D45
W: The repository 'https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu serena Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: Failed to fetch http://repository.spotify.com/dists/stable/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4773BD5E130D1D45
E: Failed to fetch https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu/dists/serena/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu/dists/serena/main/binary-amd64/Packages  404  Not Found
W: Some index files failed to download. They have been ignored, or old ones used instead.

後でgithubページで「手動インストール」を試しました... 同じ方法で失敗します。

mike@M17A ~ $  VERSION=node_10.16.3
mike@M17A ~ $  DISTRO="$(lsb_release -s -c)"
mike@M17A ~ $  echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_10.16.3 sylvia main
mike@M17A ~ $  echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
deb-src https://deb.nodesource.com/node_10.16.3 sylvia main
mike@M17A ~ $  sudo apt-get update
Hit:1 http://ppa.launchpad.net/adabbas/1stppa/ubuntu xenial InRelease
...

Ign:57 https://deb.opera.com/opera-stable stable/non-free Translation-en
Err:58 https://deb.opera.com/opera-stable stable/non-free amd64 Packages
  503  Backend unavailable, connection timeout
Ign:59 https://deb.opera.com/opera-stable stable/non-free i386 Packages
Fetched 3,316 B in 34s (95 B/s)
Reading package lists... Done
W: The repository 'https://deb.nodesource.com/node_10.x sylvia Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://repository.spotify.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4773BD5E130D1D45
W: The repository 'http://repository.spotify.com stable InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu serena Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu serena Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'https://deb.opera.com/opera-stable stable Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch https://deb.nodesource.com/node_10.x/dists/sylvia/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu/dists/serena/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu/dists/serena/main/binary-amd64/Packages  404  Not Found
E: Failed to fetch https://deb.opera.com/opera-stable/dists/stable/non-free/binary-amd64/Packages  503  Backend unavailable, connection timeout
E: Some index files failed to download. They have been ignored, or old ones used instead.

ベストアンサー1

インストールすると、Linuxディストリビューションで信頼できるとテストされたバージョンが得られますnode.jssudo apt install nodejsこれはかなり古いバージョンのソフトウェアを受け取り、一部のパッケージはそのソフトウェアの使用を拒否するという意味でもあります。たとえば、Rocket.Chatrequireの現在のバージョンは10.xに似ていますnode.js >= 12が、私の公式バージョンは10.xです。Ubuntu 20.04質問を書く当時はかなり新しい質問だったので、次のコマンドを使用しました。

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

バージョンをインストールするスクリプトを実行しますnode.js-10.x

私が知っている限り、スクリプトが文句を言う問題は、使用している一部のリポジトリの公開鍵が見つからないことです。主な問題は、rootユーザーの奇妙な設定によって発生することがよくあり、これはキーファイルに対する誤った権限を引き起こします。

解決策はディレクトリ権限を確認することです

$ ls -l /etc/apt/sources.list.d/
$ ls -l /usr/share/keyrings/

次のようにする必要があります(-rw-r--r--はい、許可644)。

-rw-r--r-- 1 root root  2206 Aug 25 00:40 nodesource.gpg

一部のファイルの出力が異なる場合は、手動で変更してください。

sudo chmod 644 /usr/share/keyrings/nodesource.gpg

おすすめ記事