
Hinweis: Dies ist teilweise gelöst, erfordert aber etwas mehr Aufmerksamkeit. Siehe Anmerkungen am Ende des OP und die Teilantwort von @Digisec.
Ich versuche, Node.js auf CentOS 7 einzurichten, aber die folgenden Befehle können die neueste Version nicht installieren. Was muss ich im folgenden Code ändern, um die neueste Version von Node.js auf CentOS 7 zu installieren?
Ich beginne mit der Eingabe node --version
, was zu . führt v0.12.7
. Dies ist eindeutig eine alte Version, da nodejs.org
angegeben wird, dass es v5.6.0
sich um die neueste stabile Version handelt.
Also gebe ich Folgendes ein, um die neueste Version von node.js zu erhalten:
cd /tmp
curl -sL https://rpm.nodesource.com/setup | bash -
Das Terminal gibt aus, dass ich Folgendes eingeben soll, um die veraltete Version von node.js zu entfernen, also gebe ich Folgendes ein:
yum remove -y nodejs npm
Das Terminal fordert mich außerdem auf, Folgendes einzugeben, um die neueste Version von node.js zu installieren, also gebe ich Folgendes ein:
yum install -y nodejs
Aber dann tippe ich node --version
erneut und das Terminal antwortet mit „ v0.12.7
erneut“ und zeigt an, dass die vorhergehenden Befehle lediglich die alte, veraltete Version erneut installiert haben.
Was muss ich also tun, um die neueste stabile Version von node.js auf der CentOS 7-Maschine zu installieren?
LAUFENDE BEMÜHUNGEN:
Gemäß dem Vorschlag von @Digisec habe ich die obigen Befehle erneut ausgeführt, diesmal jedoch die gesamte Ausgabe im folgenden Text aufgezeichnet. Bitte beachten Sie, dass die Reihenfolge jetzt, da ich sie erneut ausführe, etwas anders ist, aber das Ergebnis ist dasselbe, wie folgt:
[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]#
Dann, gemäß @Digisec'sAntwortAls nächstes habe ich Folgendes versucht:aber das Ergebnis ist immer noch, dass die richtige Version nicht installiert wird, wie Sie der folgenden Terminalausgabe entnehmen können:
[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]#
Ich besuchte dannder Knowledge Base-Artikel, auf den im Fehlerprotokoll oben verwiesen wird, habe aber festgestellt, dass ich nicht auf den vollständigen Artikel zugreifen kann, da ich kein Red Had-Kunde bin.
TEILLÖSUNG:
@Digisec hat dies teilweise gelöst, indem gezeigt wurde, wie die neue Version installiert wird, aber wir können die alte Version immer noch nicht entfernen, wodurch in Zukunft das Risiko von Konflikten besteht. Welche Schritte müssen unternommen werden, um die alte Version zu entfernen, damit die Neuinstallation sauber und vollständig sein kann?
ich fanddie Tar-URL für die alte Version v0.12.7 unter diesem LinkUnd @Digisec hat auch empfohlen, zu lesendieser andere Link, der die Verwendung des Befehls vorschlägtmake uninstall
. Ich habe das Gefühl, dass möglicherweise nur fünf oder zehn Befehle in das Terminal eingegeben werden müssen, um die alte Version v0.12.7 zu entfernen und die neue Version von nodejs neu zu installieren. Welche Befehle sind erforderlich?
Ich habe mit den folgenden Terminalbefehlen anscheinend drei Tar-Dateien auf der CentOS 7-Maschine gefunden, die sich auf Node.JS v0.12.7 beziehen:
[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 /]#
Beachten Sie, dass drei weitere TAR-Dateien markiert sind, node_modules
deren Beziehung zu v0.12.7
nicht klar ist.
Welche konkreten Befehle muss ich ausführen, um v0.12.7
alle v0.12.7
zugehörigen TAR-Dateien sicher zu deinstallieren und vom Computer zu entfernen?
Antwort1
Ich habe gerade dieVerknüpfungSie haben das hier. Sie installieren speziell Version 0.10
oder versuchen es zumindest, aber Sie haben eine neuere Version im Repo, das installiert wird. Sie müssen dem Setup für Node v5 folgen.
curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
PS: Lesen Sie die Seiten zur späteren Verwendung sorgfältig durch, insbesondere wenn Sie Befehle ausführen alsWurzel.
BEARBEITEN: Okay, es scheint, dass Sie hinzugefügt haben diereporichtig. Wenn Sie in das Repo schauen, sind Ihre Pakete da, aber das System sucht nach der falschen Version. An diesem Punkt würde ich vorschlagen.
yum clean all && yum update
Dadurch wird das zwischengespeicherte Repository gelöscht und von der Remote-Verbindung abgerufen.
Antwort:
Nach der Arbeit, die wir im Folgenden geleistet haben chat
, ist hier die richtige Antwort für Sie. nodejs v5
einwandfrei installiert. Sie haben vorher nodejs v0.12
manuell kompiliert, was bei binären Distributionen keine gute Idee ist, da Sie sonst in dieser Situation landen.
which node
ist zurückgekommen
/usr/local/bin/node
während
/usr/bin/node
hat die richtige Antwort zurückgegeben v5.x
.
An diesem Punkt haben Sie mehrere Möglichkeiten, das Problem zu beheben, aber ich würde zwei empfehlen.
- Option 1: Das ist der einfache Ausweg. Sie können Ihre bearbeiten
.bashrc
und ein hinzufügen,alias
das auf zeigtnode -> /usr/bin/node
. Das ist so einfach wie das Hinzufügen vonalias node="/usr/bin/node"
. Dadurch wird jedes Mal die richtige Version aufgerufen, aber ich kann nicht garantieren, dass es in Zukunft keine Konflikte mit Bibliotheken verursacht. - Option 2: Dies ist der schwierige Weg, aber er wird das Problem beheben. Bereinigen Sie zunächst
yum
das auf dem System installierte nodejs. Zweitens holen Sie sich das Tarball für die Version, die Sie kompiliert haben, entpacken Sie es./configure
und deinstallieren Sie es. In diesem Schritt finden Sieonlineleicht. Führen Sie abschließend eine Neuinstallationnodejs
durch durchyum
, damit sollte Ihr Problem behoben sein.
Antwort2
Was ich getan habe:
rm -f /etc/yum.repos.d/nodesource-el* curl -sL https://rpm.nodesource.com/setup_7.x | bash - yum install -y nodejs Knoten --Version
und ich bekam:
Version 7.2.0
Antwort3
CentOS 7.2, NodeJS 6.7.0 (https://nodejs.org/download/release/v6.7.0/). Manuell installieren
wget https://nodejs.org/download/release/v6.7.0/node-v6.7.0.tar.gz
./configure
make
make install
deinstallierenmake uninstall
Antwort4
Gleiches Problem hier. Was ich getan habe, um es zu lösen, war:
ALLE MÜSSEN ALS ROOT AUSGEFÜHRT WERDEN oder zumindest SUDO am Anfang jedes Befehls hinzufügen
Deinstallieren Sie nodejs - in meinem Fall node v8
yum uninstall nodejs npm
Entfernen Sie das aktuelle Repository aus /etc/yum.repos.d
rm /etc/yum.repos.d/nodesource*
Aktualisieren Sie Ihr Repository
yum update
Holen Sie sich das aktualisierte Repository - in meinem Fall Node v14
curl -sL https://rpm.nodesource.com/setup_14.x | bash -
Ich möchte ein neues Yum-Update durchführen (es ist optional)
yum update
Installieren Sie die neue Version von Node
yum install nodejs
Genießen
no code available for this