728x90

ubuntu 20.04 버전에 node.js를 설치해봅니다.

node는 서버 프로그래밍을 위한 js 런타임으로 javaScript로 확장 가능한 백엔드 기능을 개발할 수 있습니다.

 

1. CURL 설치

node를 설치하기 전 커맨드 라인 툴을 설치해야 합니다.

CURL은 서버와 통신할 수 있는 커맨드 명령어 오픈소스 툴로 아래의 명령어로 설치합니다.

$ sudo apt-get install -y curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.68.0-1ubuntu2.7).
curl set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

 

2. apt 패키지 매니저 이용하여 설치

apt 패키지 매니저를 update 합니다.

$ sudo apt update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease
.....
Get:42 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [512 B]
Fetched 22.8 MB in 4s (5470 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
48 packages can be upgraded. Run 'apt list --upgradable' to see them.

nodejs를 설치합니다.

$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (10.19.0~dfsg-3ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 48 not upgraded.

버전 확인을 통해 설치 확인을 합니다.

$ nodejs -v
v10.19.0

노드 패키지 매니저인 npm을 다운로드합니다.

$  sudo apt install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
...

npm 버전 확인을 통해 설치 확인을 합니다.

$ npm -v
6.14.4

 

node 버전이 너무 낮은 문제점이 발생하여 최신 버전으로 설치해보도록 하겠습니다.

$ curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_14_setup.sh
 

다운로드한 shell을 실행합니다.

$ sudo bash nodesource_14_setup.sh
## Installing the NodeSource Node.js 14.x repo...
## Populating apt-get cache...
+ apt-get update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Fetched 114 kB in 2s (69.3 kB/s)
Reading package lists... Done
## Confirming "focal" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_14.x/dists/focal/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
## Creating apt sources list file for the NodeSource Node.js 14.x repo...
+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x focal main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x focal main' >> /etc/apt/sources.list.d/nodesource.list
## Running `apt-get update` for you...
+ apt-get update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease
Get:4 https://deb.nodesource.com/node_14.x focal InRelease [4583 B]
Get:5 https://deb.nodesource.com/node_14.x focal/main amd64 Packages [774 B]
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease
Fetched 5357 B in 0s (11.9 kB/s)
Reading package lists... Done
## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn
 

다운로드한 버전으로 node를 설치합니다.

$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fontconfig-config fonts-dejavu-core gyp javascript-common libauthen-sasl-perl libc-ares2 libdata-dump-perl
  libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libencode-locale-perl libfile-basedir-perl
  libfile-desktopentry-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libfontconfig1 libfontenc1
  libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libhtml-form-perl libhtml-format-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl
  libhttp-message-perl libhttp-negotiate-perl libice6 libio-html-perl libio-socket-ssl-perl libio-stringy-perl
...
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  libnode-dev libnode64 node-gyp nodejs-doc npm
The following packages will be upgraded:
  nodejs
1 upgraded, 0 newly installed, 5 to remove and 46 not upgraded.
Need to get 25.4 MB of archives.
After this operatio , 87.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://deb.nodesource.com/node_14.x focal/main amd64 nodejs amd64 14.19.3-deb-1nodesource1 [25.4 MB]
Fetched 25.4 MB in 0s (61.0 MB/s)
(Reading database ... 75731 files and directories currently installed.)
Removing npm (6.14.4+ds-1ubuntu2) ...
Removing node-gyp (6.1.0-3) ...
Removing libnode-dev:amd64 (10.19.0~dfsg-3ubuntu1) ...
Removing nodejs-doc (10.19.0~dfsg-3ubuntu1) ...
dpkg: libnode64:amd64: dependency problems, but removing anyway as you requested:
 nodejs depends on libnode64 (= 10.19.0~dfsg-3ubuntu1).
...
Removing libnode64:amd64 (10.19.0~dfsg-3ubuntu1) ...
(Reading database ... 74289 files and directories currently installed.)
Preparing to unpack .../nodejs_14.19.3-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (14.19.3-deb-1nodesource1) over (10.19.0~dfsg-3ubuntu1) ...
Setting up nodejs (14.19.3-deb-1nodesource1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
Processing triggers for man-db (2.9.1-1) ...
 

node버전을 확인해 보니 제대로 설치되었습니다.

$ node -v
v14.19.3
 
 

 

728x90
반응형

+ Recent posts