최신 NodeJS 및 NPM을 Linux에 설치하는 방법

이 안내서에서는 최신 버전의 NodejsNPMCentOS, Fedora, Rocky & AlmaLinux와 같은 RHEL 기반 배포판Ubuntu & Linux Mint와 같은 Debian 기반 배포판에 설치하는 방법을 살펴볼 것입니다.

Node.js는 경량이면서 효율적인 JavaScript 플랫폼으로, Chrome의 V8 JavaScript 엔진을 기반으로 구축되었으며, NPM은 기본 NodeJS 패키지 관리자입니다. 확장 가능한 네트워크 응용 프로그램을 구축하는 데 사용할 수 있습니다.

이 페이지에서는 다음과 같은 내용을 다룹니다:

RHEL 배포판에 Node.js 설치 방법

최신 버전의 Node.jsNPM은 공식 NodeSource Enterprise Linux 저장소에서 제공되며, 이는 Nodejs 웹사이트에서 유지되며 최신 NodejsNPM 패키지를 설치하려면 시스템에 추가해야 합니다.

중요: 이전 버전의 RHEL 6 또는 CentOS 6을 실행 중인 경우 이전 배포판에서 Node.js 실행에 대해 읽어보는 것이 좋습니다.

RHEL, CentOS, Fedora, Rocky 및 Alma에 NodeJS 설치

최신 버전의 Node.js 저장소를 추가하려면 다음 명령을 root 또는 비권한 사용자로 실행합니다.

------------- For Node.js v19.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_19.x | sudo bash -
$ sudo yum install -y nodejs

------------- For Node.js v18.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
$ sudo yum install -y nodejs

------------- For Node.js v16.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
$ sudo yum install -y nodejs

------------- For Node.js v14.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
$ sudo yum install -y nodejs

선택 사항: 네이티브 애드온을 빌드하려면 시스템에 gcc-c++make과 같은 개발 도구가 필요합니다.npm에서.

# yum install gcc-c++ make
OR
# yum groupinstall 'Development Tools'

Debian, Ubuntu 및 Linux Mint에 Node.js 설치 방법

최신 버전의 Node.jsNPM은 또한 Nodejs 웹사이트에서 유지되는 공식 NodeSource Enterprise Linux 저장소에서 제공되며, 시스템에 추가하여 최신 Nodejs 및 NPM 패키지를 설치할 수 있습니다.

Ubuntu 및 Mint에 Node.js 설치

------------- For Node.js v19.x ------------- 
$ curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v18.x -------------
$ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v16.x -------------
$ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v14.x -------------
$ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

Debian에 Node.js 설치

------------- For Node.js v19.x ------------- 
$ curl -fsSL https://deb.nodesource.com/setup_19.x | bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v18.x ------------- 
$ curl -fsSL https://deb.nodesource.com/setup_18.x | bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v16.x ------------- 
$ curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v14.x ------------- 
$ curl -fsSL https://deb.nodesource.com/setup_14.x | bash - &&\
$ sudo apt-get install -y nodejs

선택 사항: gcc-c++make과 같은 개발 도구가 시스템에 있어야 npm의 네이티브 애드온을 빌드할 수 있습니다.

$ sudo apt-get install -y build-essential

리눅스에서 최신 Nodejs 및 NPM 테스트

NodejsNPM의 간단한 테스트를 하려면 다음 명령어를 사용하여 시스템에 설치된 버전을 확인할 수 있습니다:

RHEL 기반 시스템에서

# node --version
# npm --version

데비안, 우분투 및 리눅스 민트에서

$ nodejs --version
$ npm --version
Check NodeJS Version on CentOS

여기까지, NodejsNPM이 시스템에 설치되어 사용할 준비가 되었습니다.

I believe these were easy and simple steps to follow but in case of problems you faced, you can let us know and we find ways of helping you. I hope this guide was helpful to you and always remember to stay connected to Tecmint.

Source:
https://www.tecmint.com/install-nodejs-npm-in-centos-ubuntu/