参照先
Node.js — Node.js®をダウンロードするNode.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.# nvmをダウンロードしてインストールする: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash # シェルを再起動する代わりに実行する \. "$HOME/.nvm/nvm.sh" # Node.jsをダウンロードしてインストールする: nvm install 22 # Node.jsのバージョンを確認する: node -v # "v22.16.0"が表示される。 nvm current # "v22.16.0"が表示される。 # npmのバージョンを確認する: npm -v # "10.9.2"が表示される。
実行ログ
参照先にて、環境に合ったシェルスクリプトを作成します。その後、ターミナル上に貼り付けて、実行します。
# nvmをダウンロードしてインストールする: at 21:18:56
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# シェルを再起動する代わりに実行する
\. "$HOME/.nvm/nvm.sh"
# Node.jsをダウンロードしてインストールする:
nvm install 22
# Node.jsのバージョンを確認する:
node -v # "v22.16.0"が表示される。
nvm current # "v22.16.0"が表示される。
# npmのバージョンを確認する:
npm -v # "10.9.2"が表示される。
zsh: command not found: #
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16631 100 16631 0 0 117k 0 --:--:-- --:--:-- --:--:-- 117k
=> Downloading nvm from git to '/Users/koji/.nvm'
=> Cloning into '/Users/koji/.nvm'...
remote: Enumerating objects: 382, done.
remote: Counting objects: 100% (382/382), done.
remote: Compressing objects: 100% (325/325), done.
remote: Total 382 (delta 43), reused 180 (delta 29), pack-reused 0 (from 0)
Receiving objects: 100% (382/382), 385.06 KiB | 477.00 KiB/s, done.
Resolving deltas: 100% (43/43), done.
* (HEAD detached at FETCH_HEAD)
master
=> Compressing and cleaning up git repository
=> Appending nvm source string to /Users/koji/.zshrc
=> Appending bash_completion source string to /Users/koji/.zshrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
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
zsh: command not found: #
zsh: command not found: #
Downloading and installing node v22.16.0...
Downloading https://nodejs.org/dist/v22.16.0/node-v22.16.0-darwin-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)
zsh: command not found: #
v22.16.0
v22.16.0
zsh: command not found: #
10.9.2
Nodeのバージョンを確認します。
node --version
標準出力:
v22.16.0
Node.jsのインストールが確認できました。
コメント