우분투를 새로 설치하고 node.js를 새로 설치하기 위해 node.js 홈페이지에서 설치 방법을 확인하니 nvm을 이용한 방법으로 안내가 돼 있어 안내대로 했다가 permission 에러를 만났다.
홈페이지에 안내된 설치 절차는 아래와 같다.
# nvm 다운로드 및 설치:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Node.js 다운로드 및 설치:
nvm install 22
# Node.js 버전 확인:
node -v # "v22.16.0"가 출력되어야 합니다.
nvm current # "v22.16.0"가 출력되어야 합니다.
npm 버전 확인:
npm -v # 10.9.2가 출력되어야 합니다.
그런데 위 절차 중 nvm install 22 실행하는 부분에서 아래와 같은 에러가 발생했다.
Downloading and installing node v22.16.0...
Downloading https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-x64.tar.xz...
##O=- # #
Warning: Failed to open the file /home/leeky/.nvm/.cache/bin/node-v22.16.0-linux-x64/node-v22.16.0-linux-x64.tar.xz: Permission denied
curl: (23) client returned ERROR on write of 1360 bytes
download from https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-x64.tar.xz failed
grep: /home/leeky/.nvm/.cache/bin/node-v22.16.0-linux-x64/node-v22.16.0-linux-x64.tar.xz: 그런 파일이나 디렉터리가 없습니다
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 12 CPU core(s)
Running with 11 threads to speed up the build
Downloading https://nodejs.org/dist/v22.16.0/node-v22.16.0.tar.xz...
##O=- # #
Warning: Failed to open the file /home/leeky/.nvm/.cache/src/node-v22.16.0/node-v22.16.0.tar.xz: Permission denied
curl: (23) client returned ERROR on write of 1360 bytes
download from https://nodejs.org/dist/v22.16.0/node-v22.16.0.tar.xz failed
grep: /home/leeky/.nvm/.cache/src/node-v22.16.0/node-v22.16.0.tar.xz: 그런 파일이나 디렉터리가 없습니다
Provided file to checksum does not exist.
구글링 해보니 원인은 curl 이었다.
curl을 설치할 때 snap과 apt 둘 중 하나로 설치할 수 있었는데 버전이 snap쪽이 더 높아 snap을 이용해 설치했다.
그런데 snap을 이용해 설치한 것을 제거하고 apt로 설치하니 문제없이 설치됐다.
$ sudo snap remove curl
$ sudo apt install curl
$ nvm install 22
Downloading and installing node v22.16.0...
Downloading https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-x64.tar.xz...
############################################################################################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.16.0 (npm v10.9.2)
Creating default alias: default -> 22 (-> v22.16.0)