상세 컨텐츠

본문 제목

029. Raspberry Pi 라즈베리 파이 - nodejs (Binary) 설치

raspberrypi/raspbian

by ZelKun 2017. 4. 17. 18:30

본문

반응형

 

최신버전이 6인것 같으니 받아서 직접 설치를 해야겠어요

 

참고로 번거로울 없이 설치하는 방법은

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

출처: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions


nodejs 공식홈에서 지원하는 내용입니다

pi@rasp3-master:~/utils $ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

 

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

 

## Populating apt-get cache...

 

+ apt-get update

Get:1 http://archive.raspberrypi.org jessie InRelease [22.9 kB]                                                       

Get:2 http://archive.raspberrypi.org jessie/main armhf Packages [144 kB]                         

Get:3 http://archive.raspberrypi.org jessie/ui armhf Packages [57.6 kB]                                                                       

Err http://mirrordirector.raspbian.org jessie InRelease                                                                                                                             

  

Err http://mirrordirector.raspbian.org jessie Release.gpg                                                               

  Cannot initiate the connection to mirrordirector.raspbian.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 2a00:1098:0:80:1000:75:0:3 80]

100% [Connecting to archive.raspberrypi.org (46.235.227.11)]

근데 저상태로 멈춰있어서기도 하구 번거롭지만 그냥 설치할거에요 답답한 1

 

nodejs 홈페이지에서 최신버전을 받을 있습니다



출처 : http://nodejs.org

 

download 클릭합니다

 

출처 : http://nodejs.org


Linux Binaries(ARM) 중 arm7을 다운 받을거에요

물론 pi 에서요

 

 

wget https://nodejs.org/dist/v6.10.1/node-v6.10.1-linux-armv7l.tar.xz

pi@rasp2-dev:~/utils $ wget https://nodejs.org/dist/v6.10.1/node-v6.10.1-linux-armv7l.tar.xz

--2017-03-26 01:06:57--  https://nodejs.org/dist/v6.10.1/node-v6.10.1-linux-armv7l.tar.xz

Resolving nodejs.org (nodejs.org)... 104.20.22.46, 104.20.23.46, 2400:cb00:2048:1::6814:162e, ...

Connecting to nodejs.org (nodejs.org)|104.20.22.46|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 8320636 (7.9M) [application/x-xz]

Saving to: ‘node-v6.10.1-linux-armv7l.tar.xz’

 

node-v6.10.1-linux- 100%[=====================>]   7.93M   175KB/s   in 72s    

 

2017-03-26 01:08:20 (113 KB/s) - ‘node-v6.10.1-linux-armv7l.tar.xz’ saved [8320636/8320636]

 

이제 앞축을 풀어줍니다

pi@rasp2-dev:~/utils $ ls

node_latest_armhf.deb  node-v6.10.1-linux-armv7l.tar.xz

pi@rasp2-dev:~/utils $ tar -xvf node-v6.10.1-linux-armv7l.tar.xz

node-v6.10.1-linux-armv7l/

node-v6.10.1-linux-armv7l/README.md

node-v6.10.1-linux-armv7l/bin/

node-v6.10.1-linux-armv7l/bin/node

node-v6.10.1-linux-armv7l/bin/npm

 

    . . .

 

node-v6.10.1-linux-armv7l/include/node/openssl/ui_compat.h

node-v6.10.1-linux-armv7l/include/node/openssl/ssl2.h

node-v6.10.1-linux-armv7l/include/node/v8-experimental.h

node-v6.10.1-linux-armv7l/include/node/common.gypi

node-v6.10.1-linux-armv7l/include/node/v8-version.h

node-v6.10.1-linux-armv7l/include/node/nameser.h

node-v6.10.1-linux-armv7l/include/node/uv-threadpool.h

node-v6.10.1-linux-armv7l/include/node/node_buffer.h

node-v6.10.1-linux-armv7l/include/node/ares.h

node-v6.10.1-linux-armv7l/include/node/uv.h

node-v6.10.1-linux-armv7l/CHANGELOG.md

pi@rasp2-dev:~/utils $ ls

node_latest_armhf.deb  node-v6.10.1-linux-armv7l  node-v6.10.1-linux-armv7l.tar.xz

pi@rasp2-dev:~/utils $ 

 

앞축을 풀었으니 확인해봅니다

pi@rasp2-dev:~/utils $ ls -al ./node-v6.10.1-linux-armv7l/

total 160

drwxr-xr-x 6 pi pi  4096 Mar 22 04:22 .

drwxr-xr-x 3 pi pi  4096 Mar 26 12:02 ..

drwxr-xr-x 2 pi pi  4096 Mar 22 04:22 bin

-rw-r--r-- 1 pi pi 55670 Mar 22 04:22 CHANGELOG.md

drwxr-xr-x 3 pi pi  4096 Mar 22 04:22 include

drwxr-xr-x 3 pi pi  4096 Mar 22 04:22 lib

-rw-r--r-- 1 pi pi 60255 Mar 22 04:22 LICENSE

-rw-r--r-- 1 pi pi 18120 Mar 22 04:22 README.md

drwxr-xr-x 5 pi pi  4096 Mar 22 04:22 share

pi@rasp2-dev:~/utils $ ls ./node-v6.10.1-linux-armv7l/bin/

node  npm

pi@rasp2-dev:~/utils $ ./node-v6.10.1-linux-armv7l/bin/node -v

v6.10.1

 

버전이 6.10.1 최신이네요

 

2가지 방법이 있는데

  1. 현재 디렉토리를 path 추가한다
  2. 시스템 디렉토리로 옮기고 path 추가한다

2번째를 선호하니 디렉토리를 옮겨버릴거에요

path 확인합니다

pi@rasp2-dev:~/utils $ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games

/usr/local/sbin 혹은 /usr/local/bin 쪽에 몰려있나보네요

확인해봅니다

pi@rasp2-dev:~/utils $ ls /usr/local/

bin  etc  games  include  lib  man  sbin  share  src

pi@rasp2-dev:~/utils $ ls /usr/local/sbin

pi@rasp2-dev:~/utils $ ls /usr/local/bin

node  npm

pi@rasp2-dev:~/utils $ ls -al /usr/local/bin

total 11680

drwxrwsr-x  2 root staff     4096 Mar 26 11:26 .

drwxrwsr-x 10 root staff     4096 Mar  4 00:21 ..

-rwxr-xr-x  1 root staff 11949036 Oct 18  2015 node

lrwxrwxrwx  1 root staff       38 Oct 18  2015 npm -> ../lib/node_modules/npm/bin/npm-cli.js

/usr/local/bin dpkg 설치한 nodejs 남아있네요

 

전에 설치한 node 4.2.1 제거합니다

sudo dpkg -r node

pi@rasp2-dev:~/utils $ sudo dpkg -l | grep node

ii  node                           4.2.1-1                         armhf        node v4.2.1

pi@rasp2-dev:~/utils $ sudo dpkg -r node

(Reading database ... 41681 files and directories currently installed.)

Removing node (4.2.1-1) ...

dpkg: warning: while removing node, directory '/usr/local/share' not empty so not removed

dpkg: warning: while removing node, directory '/usr/local/lib' not empty so not removed

Processing triggers for man-db (2.7.0.2-5) ...

pi@rasp2-dev:~/utils $ sudo dpkg -l | grep node

pi@rasp2-dev:~/utils $ 

설치된 패키지에서 더이상 nodejs 찾을 없네요

 

그럼 압축을 node /usr/local 이동하고 path 잡아줄거에요

근데 path잡기는 귀찮으니 node, npm /usr/loca/bin 링크를 걸어줄거에요

 

sudo mv /home/pi/utils/node-v6.10.1-linux-armv7l /usr/local/

sudo ln -s /usr/local/node-v6.10.1-linux-armv7l/bin/node /usr/local/bin/node

sudo ln -s /usr/local/node-v6.10.1-linux-armv7l/bin/npm /usr/local/bin/npm

pi@rasp2-dev:~/utils $ sudo mv /home/pi/utils/node-v6.10.1-linux-armv7l /usr/local/

pi@rasp2-dev:~/utils $ sudo ln -s /usr/local/node-v6.10.1-linux-armv7l/bin/node /usr/local/bin/node

pi@rasp2-dev:~/utils $ sudo ln -s /usr/local/node-v6.10.1-linux-armv7l/bin/npm /usr/local/bin/npm

 

이제 node npm 버전을 확인해봅니다

pi@rasp2-dev:~/utils $ which node npm

/usr/local/bin/node

/usr/local/bin/npm

pi@rasp2-dev:~/utils $ node -v

v6.10.1

pi@rasp2-dev:~/utils $ npm -v

3.10.10

pi@rasp2-dev:~/utils $ 

잘되네요

 

직접설치한거니..

당연한 이야기지만 dpkg 이용해서 node 패키지를 검색하면 안나옵니다

 

삭제도 간편합니다

sudo rm /usr/loca/bin/node

sudo rm /usr/loca/bin/npm

sudo rm -rf /usr/loca/node-v6.10.1-linux-armv7l

해당 파일과 디렉토리만 삭제하면되니까요

path 안잡아줘서 path 수정도 안해도 됩니다

 

참고


반응형

관련글 더보기

댓글 영역