개발자/라즈베리파이4

Raspberry Pi4 Node.js 최신 버전 업데이트

지구빵집 2023. 1. 25. 09:33
반응형

 

 

Node.js 는 브라우저 외부에서 JavaScript 코드를 실행하는 오픈 소스 크로스 플랫폼 도구입니다. 이를 통해 개발자는 JavaScript를 활용하여 명령줄 도구 및 서버측 스크립팅을 작성할 수 있으므로 동적 웹 콘텐츠를 생성하기 위한 서버측 스크립트를 실행할 수 있습니다.

 

Node.js 는 Raspberry Pi 시스템을 포함한 대부분의 Linux 시스템에 이미 설치되어 있습니다. 그러나 업데이트된 버전은 아닙니다. 따라서 이 기사에서는 Raspberry Pi 시스템에서 Node.js 를 업데이트하는 다양한 방법을 볼 수 있습니다. 

 

Raspberry Pi 4에서 Nodejs 및 npm을 업데이트하는 방법

 

이 튜토리얼에서는 Raspberry Pi 4에서 Nodejs 및 npm을 업데이트합니다.

 

절차:

 

시작하려면 Raspberry Pi에서 터미널을 엽니다.

 

다음 명령을 사용하여 Raspberry Pi에 최신 시스템의 패키지 목록을 가져옵니다.

 

$ sudo apt update

 

pi@raspberrypi:~ $ sudo apt update
받기:1 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
받기:2 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
받기:3 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages [13.0 MB]
받기:4 http://archive.raspberrypi.org/debian buster/main armhf Packages [392 kB]
내려받기 13.5 M바이트, 소요시간 21초 (634 k바이트/초)
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
9 packages can be upgraded. Run 'apt list --upgradable' to see them.
pi@raspberrypi:~ $

 

다음으로 다음을 사용하여 Raspberry Pi에서 사용할 수 있는 최신 패키지를 설치하십시오.

 

$ sudo apt full-upgrade

 

pi@raspberrypi:~ $ sudo apt full-upgrade
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
업그레이드를 계산하는 중입니다... 완료
다음 패키지가 자동으로 설치되었지만 더 이상 필요하지 않습니다:
  libpipewire-0.2-1 xdg-desktop-portal xdg-desktop-portal-gtk
Use 'sudo apt autoremove' to remove them.
다음 패키지를 업그레이드할 것입니다:
  libsnmp-base libsnmp30 libtiff-dev libtiff5 libtiff5-dev libtiffxx5 node-minimatch rpi-eeprom sudo
9개 업그레이드, 0개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
8,193 k바이트 아카이브를 받아야 합니다.
이 작업 후 215 k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] y
받기:1 http://archive.raspberrypi.org/debian buster/main armhf rpi-eeprom armhf 15.2-1~buster [2,341 kB]
받기:2 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf libsnmp-base all 5.7.3+dfsg-5+deb10u4 [1,595 kB]
받기:3 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf libsnmp30 armhf 5.7.3+dfsg-5+deb10u4 [2,194 kB]
받기:4 http://ftp.lanet.kr/raspbian/raspbian buster/main armhf libtiff-dev armhf 4.1.0+git191117-2~deb10u5 [363 kB]
받기:5 http://ftp.lanet.kr/raspbian/raspbian buster/main armhf libtiff5 armhf 4.1.0+git191117-2~deb10u5 [251 kB]
받기:6 http://ftp.lanet.kr/raspbian/raspbian buster/main armhf libtiffxx5 armhf 4.1.0+git191117-2~deb10u5 [118 kB]
받기:7 http://ftp.lanet.kr/raspbian/raspbian buster/main armhf libtiff5-dev armhf 4.1.0+git191117-2~deb10u5 [115 kB]
받기:8 http://ftp.lanet.kr/raspbian/raspbian buster/main armhf sudo armhf 1.8.27-1+deb10u5 [1,202 kB]
받기:9 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf node-minimatch all 3.0.4-3+deb10u1 [13.8 kB]
내려받기 8,193 k바이트, 소요시간 5초 (1,610 k바이트/초)
Reading changelogs... Done
(데이터베이스 읽는중 ...현재 197314개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../0-libsnmp-base_5.7.3+dfsg-5+deb10u4_all.deb ...
Unpacking libsnmp-base (5.7.3+dfsg-5+deb10u4) over (5.7.3+dfsg-5+deb10u3) ...
Preparing to unpack .../1-libsnmp30_5.7.3+dfsg-5+deb10u4_armhf.deb ...
Unpacking libsnmp30:armhf (5.7.3+dfsg-5+deb10u4) over (5.7.3+dfsg-5+deb10u3) ...
Preparing to unpack .../2-libtiff-dev_4.1.0+git191117-2~deb10u5_armhf.deb ...
Unpacking libtiff-dev:armhf (4.1.0+git191117-2~deb10u5) over (4.1.0+git191117-2~deb10u4) ...
Preparing to unpack .../3-libtiff5_4.1.0+git191117-2~deb10u5_armhf.deb ...
Unpacking libtiff5:armhf (4.1.0+git191117-2~deb10u5) over (4.1.0+git191117-2~deb10u4) ...
Preparing to unpack .../4-libtiffxx5_4.1.0+git191117-2~deb10u5_armhf.deb ...
Unpacking libtiffxx5:armhf (4.1.0+git191117-2~deb10u5) over (4.1.0+git191117-2~deb10u4) ...
Preparing to unpack .../5-libtiff5-dev_4.1.0+git191117-2~deb10u5_armhf.deb ...
Unpacking libtiff5-dev (4.1.0+git191117-2~deb10u5) over (4.1.0+git191117-2~deb10u4) ...
Preparing to unpack .../6-rpi-eeprom_15.2-1~buster_armhf.deb ...
Unpacking rpi-eeprom (15.2-1~buster) over (13.12-1~buster) ...
Preparing to unpack .../7-sudo_1.8.27-1+deb10u5_armhf.deb ...
Unpacking sudo (1.8.27-1+deb10u5) over (1.8.27-1+deb10u4) ...
Preparing to unpack .../8-node-minimatch_3.0.4-3+deb10u1_all.deb ...
Unpacking node-minimatch (3.0.4-3+deb10u1) over (3.0.4-3) ...
libsnmp-base (5.7.3+dfsg-5+deb10u4) 설정하는 중입니다 ...
libsnmp30:armhf (5.7.3+dfsg-5+deb10u4) 설정하는 중입니다 ...
sudo (1.8.27-1+deb10u5) 설정하는 중입니다 ...
rpi-eeprom (15.2-1~buster) 설정하는 중입니다 ...
libtiff5:armhf (4.1.0+git191117-2~deb10u5) 설정하는 중입니다 ...
node-minimatch (3.0.4-3+deb10u1) 설정하는 중입니다 ...
libtiffxx5:armhf (4.1.0+git191117-2~deb10u5) 설정하는 중입니다 ...
libtiff-dev:armhf (4.1.0+git191117-2~deb10u5) 설정하는 중입니다 ...
libtiff5-dev (4.1.0+git191117-2~deb10u5) 설정하는 중입니다 ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10+rpt2+rpi1+deb10u1) ...
Processing triggers for systemd (241-7~deb10u8+rpi1) ...

 

업데이트 및 업그레이드 명령을 실행한 후 시스템이 작업을 완료했습니다.

 

이제 다음 명령을 입력하여 Nodejs 및 npm의 버전을 확인하겠습니다.

 

$ node -v

$ npm -v

 

pi@raspberrypi:~ $ node -v
v10.24.0
pi@raspberrypi:~ $ npm -v
5.8.0

 

내가 가지고 있는 nodejs(v10.19.0) 및 npm(5.8.0) 버전을 알려줍니다.

 

내 Raspberry Pi에 있는 Nodejs 및 npm의 현재 버전 내 Nodejs 버전이 v10.19.0이라는 것을 알 수 있을 것입니다. 괜찮은 수준이지만 최신 버전인 14.3.0으로 업데이트하고 싶습니다. Nodejs.org 최신 버전 두 개가 포함된 홈페이지.

 

현재 버전을 다운로드할 수 있는 Nodejs 홈페이지 또한 내 npm 버전은 5.8.0으로 오래되었습니다. 최신 버전인 v6.14.5를 원할 것입니다.

 

v6.14.5 npm을 실행하는 GitHub 웹사이트 npm의 최신 버전은 v6.14.5입니다. Nodejs와 npm의 최신 버전을 얻으려면 먼저 패키지를 제거한 다음 다시 설치하여 최신 릴리스를 받아야 합니다.

 

터미널 명령줄에서 다음 명령을 실행하십시오.

 

sudo apt remove node

 

pi@raspberrypi:~ $ sudo apt remove node
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
Package 'node' is not installed, so not removed
다음 패키지가 자동으로 설치되었지만 더 이상 필요하지 않습니다:
  libpipewire-0.2-1 xdg-desktop-portal xdg-desktop-portal-gtk
Use 'sudo apt autoremove' to remove them.
0개 업그레이드, 0개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
pi@raspberrypi:~ $

 

sudo apt remove node를 실행했지만 노드를 찾을 수 없습니다. 노드가 설치되지 않은 것 같습니다. 이제 다음을 입력하여 다음 단계로 진행하겠습니다.

 

$ sudo apt remove nodejs

 

Nodejs를 제거하려면 요청을 확인하라는 메시지가 표시되므로 명령을 진행해야 합니다. Nodejs를 계속 제거하려면 명령줄에 Y(예)를 입력합니다.

 

pi@raspberrypi:~ $ sudo apt remove nodejs
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다
상태 정보를 읽는 중입니다... 완료
다음 패키지가 자동으로 설치되었지만 더 이상 필요하지 않습니다:
  gyp libc-ares2 libjs-inherits libjs-is-typedarray libnode-dev libnode64 libpipewire-0.2-1 libuv1-dev
  nodejs-doc xdg-desktop-portal xdg-desktop-portal-gtk
Use 'sudo apt autoremove' to remove them.
다음 패키지를 지울 것입니다:
  node-abbrev node-ajv node-ansi node-ansi-align node-ansi-regex node-ansi-styles node-ansistyles node-aproba
 .
 .
 .
 
0개 업그레이드, 0개 새로 설치, 242개 제거 및 0개 업그레이드 안 함.
이 작업 후 66.1 M바이트의 디스크 공간이 비워집니다.
계속 하시겠습니까? [Y/n] y
(데이터베이스 읽는중 ...현재 197315개의 파일과 디렉터리가 설치되어 있습니다.)
.
.
.
Removing node-widest-line (1.2.2-1) ...
Removing node-co (4.6.0-1) ...
Removing node-color-convert (1.9.0-3) ...
Removing node-color-name (1.1.3-1) ...
Removing node-combined-stream (1.0.7-1) ...
Removing node-mississippi (3.0.0-1) ...
Removing node-concat-stream (1.6.2-1) ...
Removing node-config-chain (1.1.11-1) ...
Removing node-console-control-strings (1.1.0-1) ...
Processing triggers for desktop-file-utils (0.23-4) ...
pi@raspberrypi:~ $

 

Raspberry Pi 4에서 sudo apt remove nodejs를 실행했습니다. 이제 다음 명령을 사용하여 Nodejs를 다시 설치해 보겠습니다.

 

우선 npm 설치부터 

 

$ sudo apt install npm

 

Node 모듈은 최신 버전의 Node.js 를 Raspberry Pi 시스템에 설치할 수 있게 해주는 NPM(Node Package Manager) 부분입니다. 이 모듈을 설치하려면 아래 명령을 따르십시오. 

 

$ sudo npm install -g n 

 

pi@raspberrypi:~ $ sudo npm install -g n
npm WARN npm npm does not support Node.js v10.24.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@9.0.1
added 1 package from 2 contributors in 5.41s
pi@raspberrypi:~ $

 

NPM 설치 후 다음 명령을 사용하여 " n" 모듈을 통해 최신 버전의 Node.js 를 설치할 수 있습니다.

 

$ sudo n latest

 

pi@raspberrypi:~ $ sudo n latest
  installing : node-v19.4.0
       mkdir : /usr/local/n/versions/node/19.4.0
       fetch : https://nodejs.org/dist/v19.4.0/node-v19.4.0-linux-armv7l.tar.xz
     copying : node/19.4.0
   installed : v19.4.0 (with npm 9.2.0)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
If "node --version" shows the old version then start a new shell, or reset the location hash with:
hash -r  (for bash, zsh, ash, dash, and ksh)
rehash   (for csh and tcsh)
pi@raspberrypi:~ $

 

최신 설치가 완료될 때까지 기다리면 터미널 화면에 Node.js 버전 번호가 표시됩니다. 다음 명령을 통해 Node.js 업데이트 프로세스를 확인할 수 있습니다 . 

 

완벽한! 해당 명령이 적용되면 최신 버전을 얻었는지 확인합니다. 이제 다음 명령을 실행하십시오.

 

$ nodejs -v

$ node -v

$ npm -v

 

Raspberry Pi에 설치된 최신 버전의 Nodejs 및 npm. Raspberry Pi 4에 최신 Nodejs 및 npm 버전을 성공적으로 설치했습니다! 축하합니다! 

 

 

이미지 https://cdroma.medium.com/how-to-install-node-js-to-raspberry-pi-zero-other-2fbe39ad4493

 

 

 

반응형