
注: これは部分的に解決されていますが、もう少し注意が必要です。OP の下部にある注記と @Digisec の部分的な回答を参照してください。
CentOS 7 で Node.js をセットアップしようとしていますが、次のコマンドを実行しても最新バージョンのインストールに失敗します。 CentOS 7 に最新バージョンの Node.js をインストールするには、以下のコードで何を変更する必要がありますか?
まず、 と入力すると、node --version
という結果になります。は最新の安定バージョンである v0.12.7
と表示しているので、これは明らかに古いバージョンです。nodejs.org
v5.6.0
そこで、最新バージョンの node.js を取得するには、次のように入力します。
cd /tmp
curl -sL https://rpm.nodesource.com/setup | bash -
ターミナルには、古いバージョンの node.js を削除するには次のように入力する必要があると表示されるので、次のように入力します。
yum remove -y nodejs npm
ターミナルでは、最新バージョンの node.js をインストールするには次のように入力するように指示されるので、次のように入力します。
yum install -y nodejs
しかし、もう一度入力するとnode --version
、ターミナルはv0.12.7
again と応答し、前のコマンドが単に古いバージョンを再インストールしただけであることが示されます。
では、CentOS 7 マシンに最新の安定バージョンの node.js をインストールするには、何をする必要がありますか?
進行中の取り組み:
@Digisec の提案に従って、上記のコマンドを再実行しましたが、今回はすべての出力を次のテキストに記録しました。再度実行したため、シーケンスが若干異なりますが、結果は次のとおり同じであることに注意してください。
[root@localhost ~]# node --version
v0.12.7
[root@localhost ~]# cd /tmp
[root@localhost tmp]# curl -sL https://rpm.nodesource.com/setup | bash -
## Installing the NodeSource Node.js 0.10 repo...
## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m
## Confirming "el7-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.ePYEdVWXQH' 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.ePYEdVWXQH'
## Cleaning up...
+ rm -f '/tmp/tmp.ePYEdVWXQH'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `yum install -y nodejs` (as root) to install Node.js 0.10 and npm.
## You may also need development tools to build native addons:
## `yum install -y gcc-c++ make`
[root@localhost tmp]# yum remove -y nodejs npm
Loaded plugins: fastestmirror, langpacks
No Match for argument: npm
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be erased
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Removing:
nodejs x86_64 0.10.42-1nodesource.el7.centos @nodesource 16 M
Transaction Summary
====================================================================================================================================================================================
Remove 1 Package
Installed size: 16 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : nodejs-0.10.42-1nodesource.el7.centos.x86_64 1/1
Verifying : nodejs-0.10.42-1nodesource.el7.centos.x86_64 1/1
Removed:
nodejs.x86_64 0:0.10.42-1nodesource.el7.centos
Complete!
[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: www.gtlib.gatech.edu
* epel: mirror.sfo12.us.leaseweb.net
* extras: dallas.tx.mirror.xygenhosting.com
* updates: linux.mirrors.es.net
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
nodejs x86_64 0.10.42-1nodesource.el7.centos nodesource 4.5 M
Transaction Summary
====================================================================================================================================================================================
Install 1 Package
Total download size: 4.5 M
Installed size: 16 M
Downloading packages:
nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm | 4.5 MB 00:00:09
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : nodejs-0.10.42-1nodesource.el7.centos.x86_64 1/1
Verifying : nodejs-0.10.42-1nodesource.el7.centos.x86_64 1/1
Installed:
nodejs.x86_64 0:0.10.42-1nodesource.el7.centos
Complete!
[root@localhost tmp]# node --version
v0.12.7
[root@localhost tmp]#
そして、@Digisecの答え次に次のことを試しました。しかし、結果は依然として適切なバージョンのインストールに失敗しています次のターミナル出力からわかるように、
[root@localhost tmp]# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
## Installing the NodeSource Node.js 5.x repo...
## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m
## Confirming "el7-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.NEM1bxM9WB' 'https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.NEM1bxM9WB'
## Cleaning up...
+ rm -f '/tmp/tmp.NEM1bxM9WB'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `yum install -y nodejs` (as root) to install Node.js 5.x and npm.
## You may also need development tools to build native addons:
## `yum install -y gcc-c++ make`
[root@localhost tmp]# yum remove -y nodejs npm
Loaded plugins: fastestmirror, langpacks
No Match for argument: npm
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be erased
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Removing:
nodejs x86_64 0.10.42-1nodesource.el7.centos @nodesource 16 M
Transaction Summary
====================================================================================================================================================================================
Remove 1 Package
Installed size: 16 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : nodejs-0.10.42-1nodesource.el7.centos.x86_64 1/1
Verifying : nodejs-0.10.42-1nodesource.el7.centos.x86_64 1/1
Removed:
nodejs.x86_64 0:0.10.42-1nodesource.el7.centos
Complete!
[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: www.gtlib.gatech.edu
* epel: mirror.sfo12.us.leaseweb.net
* extras: dallas.tx.mirror.xygenhosting.com
* updates: linux.mirrors.es.net
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
nodejs x86_64 0.10.42-1nodesource.el7.centos nodesource 4.5 M
Transaction Summary
====================================================================================================================================================================================
Install 1 Package
Total download size: 4.5 M
Installed size: 16 M
Downloading packages:
nodejs-0.10.42-1nodesource.el7 FAILED
https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found ] 0.0 B/s | 0 B --:--:-- ETA
Trying other mirror.
To address this issue please refer to the below knowledge base article
https://access.redhat.com/articles/1320623
If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/
Error downloading packages:
nodejs-0.10.42-1nodesource.el7.centos.x86_64: [Errno 256] No more mirrors to try.
[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: www.gtlib.gatech.edu
* epel: mirror.sfo12.us.leaseweb.net
* extras: dallas.tx.mirror.xygenhosting.com
* updates: linux.mirrors.es.net
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
nodejs x86_64 0.10.42-1nodesource.el7.centos nodesource 4.5 M
Transaction Summary
====================================================================================================================================================================================
Install 1 Package
Total download size: 4.5 M
Installed size: 16 M
Downloading packages:
No Presto metadata available for nodesource
nodejs-0.10.42-1nodesource.el7 FAILED
https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found ] 0.0 B/s | 0 B --:--:-- ETA
Trying other mirror.
To address this issue please refer to the below knowledge base article
https://access.redhat.com/articles/1320623
If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/
Error downloading packages:
nodejs-0.10.42-1nodesource.el7.centos.x86_64: [Errno 256] No more mirrors to try.
[root@localhost tmp]# node --version
v0.12.7
[root@localhost tmp]#
私はその後訪問した上記のエラーログで参照されているナレッジベースの記事しかし、私は Red Had の顧客ではないため、記事全体にアクセスできないことがわかりました。
部分的な解決策:
@Digisec は、新しいバージョンのインストール方法を示すことでこの問題を部分的に解決しましたが、古いバージョンを削除することはまだできないため、今後も競合のリスクが残ります。 新しいインストールがクリーンかつ完全なものになるように、古いバージョンを削除するにはどのような手順を実行する必要がありますか?
私は見つけたこのリンクの古いバージョン v0.12.7 の tar URL. そして@Digisec'も読むことを勧めているこの他のリンクでは、コマンドの使用を提案していますmake uninstall
。 古い v0.12.7 を削除して、新しいバージョンの nodejs を再インストールするには、ターミナルに入力するコマンドは 5 個か 10 個しかないのではないかと思います。必要なコマンドは何ですか?
次のターミナル コマンドを使用して、CentOS 7 マシン上で nodejs v0.12.7 に関連する 3 つの tar ファイルを見つけたようです。
[root@localhost ~]# cd /
[root@localhost /]# find . -type f -iname "*.tar"
find: ‘./run/user/1000/gvfs’: Permission denied
./opt/node-v0.12.7/deps/npm/node_modules/tar/test/dir-normalization.tar
./opt/node-v0.12.7/deps/npm/test/fixtures/gitignore-and-npmignore-2.tar
./opt/node-v0.12.7/deps/npm/test/fixtures/gitignore-and-npmignore.tar
./usr/local/lib/node_modules/npm/test/fixtures/gitignore-and-npmignore-2.tar
./usr/local/lib/node_modules/npm/test/fixtures/gitignore-and-npmignore.tar
./usr/local/lib/node_modules/npm/node_modules/tar/test/dir-normalization.tar
[root@localhost /]#
node_modules
関係がv0.12.7
明確でない tar ファイルがさらに 3 つマークされていることに注意してください。
マシンから関連するv0.12.7
すべてのtar ファイルを安全にアンインストールして削除するには、具体的にどのようなコマンドを実行すればよいですか?v0.12.7
答え1
私はちょうどリンクこれを入手しました。具体的には、バージョン をインストールしている0.10
か、少なくともインストールしようとしていますが、インストールされているリポジトリには新しいバージョンがあります。node v5 のセットアップに従う必要があります。
curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
追伸: 今後の参考のために、特にコマンドを実行するときはサイトを注意深く読んでください。根。
編集: わかりました。レポ正しく。リポジトリを確認すると、パッケージは存在しますが、システムは間違ったバージョンを探しています。この時点で、私は提案します。
yum clean all && yum update
これにより、キャッシュされたリポジトリが消去され、リモートから取得されます。
答え:
で作業を行った後chat
、正しい答えがここにあります。nodejs v5
正常にインストールされました。 以前はnodejs v0.12
手動でコンパイルしましたが、バイナリ ディストリビューションではこの位置になってしまうため、これは良い考えではありません。
which node
戻ってきた
/usr/local/bin/node
その間
/usr/bin/node
正解は でしたv5.x
。
この時点では、修正するためのオプションは複数ありますが、私は 2 つをお勧めします。
- オプション1: これは簡単な方法です。 を編集して
.bashrc
、 をalias
指すを追加しますnode -> /usr/bin/node
。 これは を追加するのと同じくらい簡単ですalias node="/usr/bin/node"
。 これにより、毎回正しいバージョンが呼び出されますが、将来的にライブラリとの競合が発生しないという保証はありません。 - オプション2: これは難しい方法ですが、修正できます。まず、
yum
システムにインストールされているNode.jsでpurgeします。次に、コンパイルしたバージョンのtarballを入手し、解凍して./configure
アンインストールします。この手順は、オンライン簡単にできます。最後に、nodejs
から再インストールするyum
と、問題が解決するはずです。
答え2
私がしたこと:
rm -f /etc/yum.repos.d/nodesource-el* curl -sL https://rpm.nodesource.com/setup_7.x | bash - yum インストール -y nodejs ノード --version
そして私は得た:
バージョン7.2.0
答え3
CentOS 7.2、NodeJS 6.7.0 (https://nodejs.org/download/release/v6.7.0/)。手動でインストールする
wget https://nodejs.org/download/release/v6.7.0/node-v6.7.0.tar.gz
./configure
make
make install
アンインストールするmake uninstall
答え4
私も同じ問題です。解決するために私がしたことは次のとおりです。
すべてはルートとして実行されるか、少なくとも各コマンドの先頭にSUDOを追加する必要があります。
Node.jsをアンインストールします - 私の場合はNode.js v8です
yum uninstall nodejs npm
/etc/yum.repos.d から実際のリポジトリを削除します。
rm /etc/yum.repos.d/nodesource*
リポジトリを更新する
yum update
更新されたリポジトリを取得します - 私の場合はNode v14です
curl -sL https://rpm.nodesource.com/setup_14.x | bash -
新しい yum アップデートを実行するのが好きです (オプションです)
yum update
新しいバージョンのノードをインストールする
yum install nodejs
楽しむ
no code available for this