
참고: 이 문제는 부분적으로 해결되었지만 좀 더 주의가 필요합니다. 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
다시 응답하여 이전 명령이 이전 버전을 다시 설치했음을 보여줍니다.
그러면 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과 관련된 세 개의 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
방금 확인했어요링크당신은 이것을 얻었습니다. 구체적으로 version 을 설치 중이 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
시스템에 설치된 nodejs로 제거합니다. 둘째, 컴파일한 버전의 tarball을 가져와 압축을 풀고./configure
제거합니다. 이 단계에서 찾을 수 있습니다.온라인용이하게. 마지막으로 을(를)nodejs
통해 다시 설치yum
하면 문제가 해결됩니다.
답변2
제가 한:
rm -f /etc/yum.repos.d/nodesource-el* 컬 -sL https://rpm.nodesource.com/setup_7.x | 배쉬 - 냠 설치 -y nodejs 노드 --버전
그리고 나는 다음을 얻었다:
v7.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를 추가해야 합니다.
nodejs 제거 - 내 경우에는 node 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