[Node.js] NVM으로 여러 버전의 node.js 사용하기
NVM(Node Version Manager)는 여러 버전의 Node.js를 사용할 수 있게 관리하는 패키지이다.
node.js자체가 NPM(Node Package Manager)에 의해 수많은 모듈들이 관리되고 기여하는 생태계라는 것을 염두에 둔다면 각 버전 별로 종속성을 갖게 된다는 것을 이해할 수 있을 것이다.
1. NVM의 설치
https://github.com/coreybutler/nvm-windows/
난 기존에 설치된 node.js를 전부 삭제하고 새 폴더를 만들어 nvm을 설치했다.
폴더 내부에는 내가 설치할 노드 버전들이 위치하기 때문에 관리하기도 매우 수월하다.
2. nvm --help
$ nvm --help
Running version 1.1.9.
Usage:
nvm arch : Show if node is running in 32 or 64 bit mode.
nvm current : Display active version.
nvm install <version> [arch] : The version can be a specific version, "latest" for the latest current version, or "lts" for the
most recent LTS version. Optionally specify whether to install the 32 or 64 bit version (defaults
to system arch). Set [arch] to "all" to install 32 AND 64 bit versions.
Add --insecure to the end of this command to bypass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm use [version] [arch] : Switch to use the specified version. Optionally use "latest", "lts", or "newest".
"newest" is the latest installed version. Optionally specify 32/64bit architecture.
nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
nvm root [path] : Set the directory where nvm should store different versions of node.js.
If <path> is not set, the current root will be displayed.
nvm version : Displays the current running version of nvm for Windows. Aliased as v.
nvm의 명령어 확인
3. nvm list available
$ nvm list available
| CURRENT | LTS | OLD STABLE | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
| 18.6.0 | 16.16.0 | 0.12.18 | 0.11.16 |
| 18.5.0 | 16.15.1 | 0.12.17 | 0.11.15 |
| 18.4.0 | 16.15.0 | 0.12.16 | 0.11.14 |
| 18.3.0 | 16.14.2 | 0.12.15 | 0.11.13 |
| 18.2.0 | 16.14.1 | 0.12.14 | 0.11.12 |
| 18.1.0 | 16.14.0 | 0.12.13 | 0.11.11 |
| 18.0.0 | 16.13.2 | 0.12.12 | 0.11.10 |
| 17.9.1 | 16.13.1 | 0.12.11 | 0.11.9 |
| 17.9.0 | 16.13.0 | 0.12.10 | 0.11.8 |
| 17.8.0 | 14.20.0 | 0.12.9 | 0.11.7 |
| 17.7.2 | 14.19.3 | 0.12.8 | 0.11.6 |
| 17.7.1 | 14.19.2 | 0.12.7 | 0.11.5 |
| 17.7.0 | 14.19.1 | 0.12.6 | 0.11.4 |
| 17.6.0 | 14.19.0 | 0.12.5 | 0.11.3 |
| 17.5.0 | 14.18.3 | 0.12.4 | 0.11.2 |
| 17.4.0 | 14.18.2 | 0.12.3 | 0.11.1 |
| 17.3.1 | 14.18.1 | 0.12.2 | 0.11.0 |
| 17.3.0 | 14.18.0 | 0.12.1 | 0.9.12 |
| 17.2.0 | 14.17.6 | 0.12.0 | 0.9.11 |
| 17.1.0 | 14.17.5 | 0.10.48 | 0.9.10 |
This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases
설치 가능한 버전들의 리스트가 나온다.
4. nvm install
$ nvm install 18.6.0
Downloading node.js version 18.6.0 (64-bit)...
Extracting...
Complete
Installation complete. If you want to use this version, type
nvm use 18.6.0
최신 버전의 node.js를 설치한다.
5. nvm use [version]
$ nvm use 18.6.0
Now using node v18.6.0 (64-bit)
6. nvm alias
# 사용할 Node alias로 설정
$ nvm alias grafana 16.13.0 # nvm alias <alias> <version>
$ nvm use grafana
단 Windows는 안된다고 함 ㅎㅎ(https://github.com/coreybutler/nvm-windows/issues/503)
'Back-end' 카테고리의 다른 글
Redis의 분산락 사용에 대해서 (0) | 2024.07.19 |
---|---|
[C#] using 구문 (1) | 2022.09.08 |
[C#] ??(null 병합 연산자 ), ??=(null 병합 할당 연산자), ?.(null 조건 연산자) (0) | 2022.06.20 |
[.NET] .NET Eco System 용어 정리 (ASP.NET, ASP.NET MVC, ADO.NET Core, ADO.NET, cshtml ...) (0) | 2022.06.06 |
[Node.js] Node.js 설치 및 REPL 터미널 실행 (0) | 2022.05.14 |