폐쇄망 nvm 설치 (CentOS7)

김민영·2023년 11월 27일
0

기타 공부

목록 보기
2/2

NVM

  • Node Version Manager - 노드 버전을 쉽게 관리할 수 있는 프로그램

설치 방법

1. 온라인 환경

  • 온라인 환경에서 설치 스크립트를 다운로드 받고, 실행한다.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

또는

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  • 다음과 같은 형태의 로그가 나온다
$ bash nvm_install.sh 
=> Downloading nvm as script to '/root/.nvm'

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:

/home1/node-v14.19.0-linux-x64/lib
├── corepack@0.10.0
=> If you wish to uninstall them at a later point (or re-install them under you
=> `nvm` Nodes), you can remove them from the system Node as follows:

     $ nvm use system
     $ npm uninstall -g a_module

=> Close and reopen your terminal to start using nvm or run the following to us

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This load
  • /root/.nvm 파일을 오프라인 환경으로 이동한다.

2. 오프라인 환경

  • /root/.nvm 파일을 위치한다.
  • /root/.bashrc 파일 최하단에 다음 내용을 추가한다.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

  • 터미널 재실행 또는 source ~/.bashrc 를 통해 입력 내용을 반영한다.
  • nvm 설치를 확인한다.

NVM repository 변경

사용법

node 설치

  • nvm install node : 최신 버전 설치
  • nvm install [버전] : 특정 버전 설치
  • nvm install node --lts : 최신 lts 버전 설치

사용 버전 변경

  • nvm use [버전]

설치 리스트 확인

  • nvm ls
  • nvm ls-remote : 설치 가능한 버전 리스트 확인
  • nvm ls-remote --lts : 설치 가능한 lts 버전 리스트 확인

참고

  • CentOS7에서 사용시, 시스템에서 사용하는 node 버전을 바꾸게 되므로 주의
  • node와 linux 에서 지원하는 버전 확인 필요
  • nvm 관련 파일을 그대로 윈도우 환경에 옮겼다가 linux 환경에 옮기면 사용 불가
    • file link 정보가 사라지게 됨
    • tar.gz 등으로 압축해서 이동 필요
profile
노션에 1차 정리합니당 - https://cream-efraasia-f3c.notion.site/4fb02c0dc82e48358e67c61b7ce8ab36?v=

0개의 댓글