이제 ssh 접속이 가능해졌다.
이 서버에 nodejs를 설치한 다음 구동해서, 외부에서 접속해보자.
ssh로 접속 후 nodejs라고 쳐 보면 현재 없다고 나온다. 그리고 친절하게도 받는 방법도 설명해준다.
helloworld@raspberry4:~$ nodejs
Command 'nodejs' not found, but can be installed with:
sudo apt install nodejs
sudo apt install nodejs
라고 입력해보자. 그러면 설치가 진행된다.
모든 프로그레스가 지나가고 나면 nodejs --version
로 설치를 확인해보자.
helloworld@raspberry4:~$ nodejs --version
v12.21.0
helloworld@raspberry4:~$
nodejs.org에서 패키지 형태로 다운로드를 받아 설치를 한다면 npm도 같이 설치된다. mac에서는 이렇게 설치하는 것이 더 편하다. 그렇지만 라즈베리파이에서 위와 같이 nodejs를 설치하고 나면 npm 역시 별도로 설치해주어야 한다.
이번에도 sudo apt install npm
으로 설치해보자.
helloworld@raspberry4:~$ npm
Command 'npm' not found, but can be installed with:
sudo apt install npm
helloworld@raspberry4:~$ sudo apt install npm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
:
엄청난 스크롤
:
다 설치하고 나면 버전을 확인할 수 있다.
helloworld@raspberry4:~$ npm --version
7.5.2
최근 npm 만큼 javascript 패키지 관리자로 유명한 것이 yarn이다.
터미널에 yarn이라고 입력하면 아래와 같이 나오는데 속지 말자.
helloworld@raspberry4:~$ yarn
Command 'yarn' not found, but can be installed with:
sudo apt install cmdtest
이렇게 sudo apt install cmdtest
이후 몇몇 시도를 해도 yarn의 흔히 보던 결과와 맞지 않다. 이것은 yarn 공식 repository와 맞지 않아서 일어난 일인것 같다.
helloworld@raspberry4:~$ sudo apt install cmdtest
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
:
helloworld@raspberry4:~$ yarn
00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.
helloworld@raspberry4:~$ cd Documents/
helloworld@raspberry4:~/Documents$ mkdir yarntest
helloworld@raspberry4:~/Documents$ cd yarntest/
helloworld@raspberry4:~/Documents/yarntest$ yarn init
00h00m00s 0/0: : ERROR: [Errno 2] No such file or directory: 'init'
위의 cmdtest 설치는 따라하지 말고 혹시 설치해버렸다면 sudo apt autoremove cmdtest
로 없애버리자.
이왕 npm을 설치했으므로 npm을 통해 yarn을 설치하자. 모든 곳에서 항상 사용할 것이므로 글로벌하게 -g 추가.
sudo npm install -g yarn
이제 yarn init
을 하면 아래와 같이 정상적으로 javascript 프로젝트를 시작할 준비를 한다.
helloworld@raspberry4:~/Documents/yarntest$ yarn init
yarn init v1.22.10
question name (yarntest):
(샘플 프로젝트 구동은 다음글에서)