Debian Stretchに最新のNodeJSをインストールすることはできません。

Debian Stretchに最新のNodeJSをインストールすることはできません。

私はDebian 9.3を使用しています。私はNodeJSに行きましたウェブサイト私のコンピュータにNodeJS v9.Xをインストールし、提供されたコードを実行する方法を学びます。

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

ところが端末でこのようなメッセージが出た。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
nodejs is already the newest version (4.8.2~dfsg-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

私のコンピュータはNodeJS v4.8.2とNPM v1.4.21で停止しました。

最新のNodeJSとNPMにアップグレードするには?

修正する

@GAD3Rの指示に従いました。それでもv4.8.2をインストールします。これはGAD3Rのコマンドを実行してからsudo apt install nodejs

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libuv1
The following NEW packages will be installed:
  libuv1 nodejs
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,524 kB of archives.
After this operation, 14.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package libuv1:amd64.
(Reading database ... 141225 files and directories currently installed.)
Preparing to unpack .../libuv1_1.9.1-3_amd64.deb ...
Unpacking libuv1:amd64 (1.9.1-3) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.8.2~dfsg-1_amd64.deb ...
Unpacking nodejs (4.8.2~dfsg-1) ...
Setting up libuv1:amd64 (1.9.1-3) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up nodejs (4.8.2~dfsg-1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

を実行するとupdate-alternatives --config nodejs端末が印刷されます。update-alternatives: error: no alternatives for nodejs

==

走ってみるとapt-cache policy nodejsこんな感じです...

nodejs:
  Installed: 4.8.2~dfsg-1
  Candidate: 4.8.2~dfsg-1
  Version table:
     9.3.0-1nodesource1 500
        500 https://deb.nodesource.com/node_9.x stretch/main amd64 Packages
     8.9.3~dfsg-2 1
          1 http://ftp.us.debian.org/debian experimental/main amd64 Packages
     6.12.0~dfsg-2 500
        500 http://ftp.us.debian.org/debian unstable/main amd64 Packages
 *** 4.8.2~dfsg-1 990
        990 http://ftp.us.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status

==

sudo /etc/apt/preferencesこれまで存在しなかった を実行し、次のように書きました。

Package: *
Pin: release n=experimental
Pin-Priority: 100

Package: *
Pin: release n=unstable
Pin-Priority: 100

Package: *
Pin: release n=stable
Pin-Priority: 500

GAD3Rの投稿にあるコマンドを再実行しましたが、Debianはまだv4.8.2nodejsパッケージをインストールしました。

ベストアンサー1

バージョン 4.8.2 は、apt次のようにインストールされます。メイン倉庫

ランニング:

apt purge nodejs
apt install lsb-release
apt install -y nodejs

インストールされたバージョンの確認nodjs:

node --version
v9.3.0

バージョンnpm:

npm --version
5.5.1

問題はピンの優先順位にあります。安定版をピンの優先順位に固定します。500

Package: *
Pin: release n=experimental 
Pin-Priority: 100

不安定:

Package: *
Pin: release n=unstable
Pin-Priority: 100

安定したものもあります:

Package: *
Pin: release n=stable
Pin-Priority: 500

問題は次のように解決されます。

シナプティックを開き、nodejsを検索し、CTRL + Eを押してバージョンを選択し、nodsource1変更を適用します。

おすすめ記事