Catatan: Ini sebagian diselesaikan, tetapi perlu sedikit lebih banyak perhatian. Lihat catatan di bagian bawah OP, dan jawaban parsial @ Digisec.
Saya mencoba mengatur Node.js pada CentOS 7, tetapi perintah berikut gagal menginstal versi terbaru. Apa yang harus saya ubah dalam kode di bawah ini untuk menginstal versi terbaru Node.js di CentOS 7?
Saya mulai dengan mengetik node --version
yang menghasilkan v0.12.7
. Ini jelas merupakan versi lama karena nodejs.org
mengatakan itu v5.6.0
adalah versi stabil terbaru.
Jadi saya ketik yang berikut ini untuk mendapatkan versi terbaru dari node.js:
cd /tmp
curl -sL https://rpm.nodesource.com/setup | bash -
Terminal mencetak bahwa saya harus mengetik yang berikut untuk menghapus versi node.js yang sudah usang, jadi saya ketik yang berikut ini:
yum remove -y nodejs npm
Terminal juga mengatakan untuk mengetik berikut ini untuk menginstal versi terbaru dari node.js, jadi saya ketik yang berikut:
yum install -y nodejs
Tapi kemudian saya mengetik node --version
lagi, dan terminal membalas dengan v0.12.7
lagi, menunjukkan bahwa perintah sebelumnya, cukup menginstal ulang versi lama yang sudah usang.
Jadi apa yang harus saya lakukan untuk mendapatkan versi stable terbaru dari node.js yang terinstal pada mesin CentOS 7?
UPAYA YANG TERJADI:
Sesuai saran @ Digisec, saya menjalankan kembali perintah di atas, tetapi kali ini mencatat semua output ke dalam teks berikut. Harap perhatikan bahwa urutannya sedikit berbeda sekarang karena saya menjalankannya lagi, tetapi hasilnya sama, sebagai berikut:
[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]#
Kemudian, sesuai jawaban @ Digisec , saya selanjutnya mencoba yang berikut, tetapi hasilnya masih gagal untuk menginstal versi yang tepat , seperti yang Anda lihat dari output terminal berikut:
[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]#
Saya kemudian mengunjungi artikel basis pengetahuan yang dirujuk oleh log kesalahan di atas , tetapi menemukan bahwa saya tidak dapat mengakses artikel lengkap karena saya bukan pelanggan Red Had.
SOLUSI parsial:
@Digisec menyelesaikan sebagian ini dengan menunjukkan cara menginstal versi baru, tetapi kami masih tidak dapat menghapus versi yang lama, yang akan meninggalkan risiko konflik ke depan. Langkah apa yang perlu diambil untuk menghapus versi lama agar instalasi baru dapat bersih dan lengkap?
Saya menemukan url tar untuk versi lama v0.12.7 di tautan ini . Dan @Digisec 'juga menyarankan untuk membaca tautan lain ini, yang menyarankan menggunakan perintahmake uninstall
. Saya mendapatkan pengertian bahwa mungkin hanya ada lima atau sepuluh perintah untuk mengetik di terminal untuk menghapus v0.12.7 lama dan menginstal ulang versi baru dari nodejs. Apa saja perintah yang diperlukan?
Saya tampaknya telah menemukan tiga file tar pada mesin CentOS 7 yang terkait dengan nodejs v0.12.7 menggunakan perintah terminal berikut:
[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 /]#
Perhatikan bahwa ada tiga file tar tambahan node_modules
yang ditandai hubungannya v0.12.7
tidak jelas.
Apa perintah khusus yang saya jalankan untuk menghapus v0.12.7
dan menghapus semua v0.12.7
file tar terkait dengan aman dari mesin?
yum remove -y nodejs
.