在 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 了!

相关推荐
hoLzwEge2 天前
pnpm vs npm:新一代包管理器的范式革命
前端框架·node.js
麻辣凉茶2 天前
给阿嬤一封来自云端的信(上)
前端·node.js
Mintimate2 天前
WorkBuddy 上手: 让脚本项目 Homebrew CN 变成会排障的 Agent
macos·边缘计算·agent
codingWhat3 天前
能效平台设计方案(打通gitlab和飞书)
后端·node.js·koa
fthux4 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
见过夏天4 天前
Node.js 常用命令全攻略
node.js
前端双越老师5 天前
我从 0 开发的 AI Agent 智语项目发布了
前端·node.js·agent
kyriewen5 天前
2026 年了,还在用 Node.js?Bun 迁移实战:20 分钟搞定,附踩坑记录
前端·javascript·node.js
donecoding6 天前
3 条命令搞定闭环 Monorepo:Lerna 版本管理 + 拓扑构建 + 自定义分发
前端·前端框架·node.js
counterxing6 天前
最近发现一个 Mac 工具,有点像把 Raycast、语音输入法、截图和录屏塞到了一起
macos·ai编程·claude