在 Mac ARM 架构上使用 nvm 安装 Node.js 版本 16.20.2

文章目录

      • [1. 安装 nvm(如果还没有安装的话)](#1. 安装 nvm(如果还没有安装的话))
      • [2. 加载 nvm 配置](#2. 加载 nvm 配置)
      • [3. 列出特定系列的 Node.js 版本(远程):](#3. 列出特定系列的 Node.js 版本(远程):)
      • [4. 安装 Node.js 16.20.2](#4. 安装 Node.js 16.20.2)
      • [5. 使用指定版本的 Node.js](#5. 使用指定版本的 Node.js)
      • [6. 验证安装](#6. 验证安装)

在 Mac ARM 架构上使用 nvm 安装 Node.js 版本 16.20.2,你可以按照以下步骤操作:

1. 安装 nvm(如果还没有安装的话)

在终端中运行以下命令来安装 nvm:

bash 复制代码
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
shell 复制代码
dgq@dgqdeMacBook-Pro ~ % curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16563  100 16563    0     0  20527      0 --:--:-- --:--:-- --:--:-- 20524
You may be on a Mac, and need to install the Xcode Command Line Developer Tools.
If so, run `xcode-select --install` and try again. If not, please report this!
shell 复制代码
dgq@dgqdeMacBook-Pro ~ % xcode-select --install

xcode-select: note: install requested for command line developer tools
shell 复制代码
dgq@dgqdeMacBook-Pro ~ % curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16563  100 16563    0     0  24655      0 --:--:-- --:--:-- --:--:-- 24647
=> nvm is already installed in /Users/dgq/.nvm, trying to update using git
=> * (HEAD detached at FETCH_HEAD)
  master
=> Compressing and cleaning up git repository

=> Appending nvm source string to /Users/dgq/.zshrc
=> Appending bash_completion source string to /Users/dgq/.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

2. 加载 nvm 配置

安装完成后,你需要重新加载 shell 配置文件,以便在终端中使用 nvm 命令。如果你使用的是 zsh,运行:

bash 复制代码
source ~/.zshrc
shell 复制代码
dgq@dgqdeMacBook-Pro ~ % nvm -v
0.40.1

如果你使用 bash,运行:

bash 复制代码
source ~/.bash_profile

3. 列出特定系列的 Node.js 版本(远程):

shell 复制代码
dgq@dgqdeMacBook-Pro ~ % nvm ls-remote | grep v16.
        v16.0.0
        v16.1.0
        v16.2.0
        v16.3.0
        v16.4.0
        v16.4.1
        v16.4.2
        v16.5.0
        v16.6.0
        v16.6.1
        v16.6.2
        v16.7.0
        v16.8.0
        v16.9.0
        v16.9.1
       v16.10.0
       v16.11.0
       v16.11.1
       v16.12.0
       v16.13.0   (LTS: Gallium)
       v16.13.1   (LTS: Gallium)
       v16.13.2   (LTS: Gallium)
       v16.14.0   (LTS: Gallium)
       v16.14.1   (LTS: Gallium)
       v16.14.2   (LTS: Gallium)
       v16.15.0   (LTS: Gallium)
       v16.15.1   (LTS: Gallium)
       v16.16.0   (LTS: Gallium)
       v16.17.0   (LTS: Gallium)
       v16.17.1   (LTS: Gallium)
       v16.18.0   (LTS: Gallium)
       v16.18.1   (LTS: Gallium)
       v16.19.0   (LTS: Gallium)
       v16.19.1   (LTS: Gallium)
       v16.20.0   (LTS: Gallium)
       v16.20.1   (LTS: Gallium)
       v16.20.2   (Latest LTS: Gallium)

4. 安装 Node.js 16.20.2

使用 nvm 安装指定的 Node.js 版本(16.20.2):

shell 复制代码
dgq@dgqdeMacBook-Pro ~ % nvm install 16
Downloading and installing node v16.20.2...
Downloading https://nodejs.org/dist/v16.20.2/node-v16.20.2-darwin-arm64.tar.xz...
########################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.20.2 (npm v8.19.4)
Creating default alias: default -> 16 (-> v16.20.2)
bash 复制代码
nvm install 16.20.2

5. 使用指定版本的 Node.js

安装完成后,可以使用以下命令来切换到该版本:

bash 复制代码
nvm use 16.20.2

6. 验证安装

检查 Node.js 是否安装成功:

bash 复制代码
node -v
shell 复制代码
dgq@dgqdeMacBook-Pro ~ % node -v
v16.20.2
shell 复制代码
dgq@dgqdeMacBook-Pro ~ % corepack -v
0.17.0

这应该会输出 v16.20.2,表示安装成功。

这样,你就可以在 Mac ARM 架构上通过 nvm 安装并使用 Node.js 16.20.2 了!

相关推荐
Digitally6 小时前
如何将 iPad 上的视频无损传输到 Mac
macos·音视频·ipad
Maynor9966 小时前
Codex 中国站正式上线!
人工智能·gpt·macos·github
XuecWu37 小时前
【Mac系统】一次 Keychain 异常导致的 Trae 卡死问题排查
macos
网络点点滴8 小时前
NPM的包版本管理
前端·npm·node.js
青山_FPGA8 小时前
以太网 MAC-PHY 接口总结
嵌入式硬件·macos
Allen正心正念20259 小时前
前端——Node.js&npm,学点前端的东西
前端·npm·node.js
小锋学长生活大爆炸9 小时前
【开源软件】打造 macOS 纯本地 LLM 工作台 | Sidekick
macos·llm
bleuesprit9 小时前
MAC 电脑快速打开claude code 终端
macos
雨声不在10 小时前
mac-intel安装git-lfs
git·elasticsearch·macos
. . . . .10 小时前
Node.js 模块系统
node.js