본문 바로가기

리눅스

CentOS 7에 Node.js와 npm을 설치하는 방법

반응형

CentOS 7에 Node.js와 npm을 설치하는 방법

1. EPEL 저장소 추가 및 curl 패키지 설치

sudo yum install -y epel-release
sudo yum install -y curl

n1

2. NodeSource 저장소 추가

curl -fsSL https://rpm.nodesource.com/setup_17.x | sudo bash -
$ curl -fsSL https://rpm.nodesource.com/setup_17.x | bash -

## Installing the NodeSource Node.js 17.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release || rpm -q --whatprovides fedora-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_17.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.CHoUa6nL51' 'https://rpm.nodesource.com/pub_17.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.CHoUa6nL51'

## Cleaning up...

+ rm -f '/tmp/tmp.CHoUa6nL51'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 17.x and npm.
## You may run dnf if yum is not available:
     sudo dnf install -y nodejs
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

3. Node.js(Node.js 17) 설치

yum install -y nodejs
$ yum install -y nodejs
...
Dependencies Resolved

==================================================================
 Package      Arch      Version                 Repository   Size
==================================================================
Installing:
 nodejs       x86_64    2:17.8.0-1nodesource    nodesource   32 M
728x90

4. npm 설치

Node.js를 설치하면 npm도 함께 설치됩니다.

5. 설치 확인

  • Node.js 버전 정보 확인
node --version
$ node --version
v17.8.0
  • npm 버전 정보 확인
npm --version
$ npm --version
8.5.5

nodeJS-image-upload 실행

  • git clone
git clone https://github.com/niinpatel/nodejs-image-upload.git
$ git clone https://github.com/niinpatel/nodejs-image-upload.git
Cloning into 'nodejs-image-upload'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 20 (delta 0), reused 0 (delta 0), pack-reused 16
Unpacking objects: 100% (20/20), done.
  • nodejs-image-upload 설치 및 실행
cd nodejs-image-upload
npm install && npm start
$ npm install && npm start
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

added 71 packages, and audited 72 packages in 4s

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> node-image-upload@1.0.0 start
> node server

Listening at 3000
  • 브라우저 : http://{SERVER IP}:3000

r2

 

728x90
반응형