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

相关推荐
吴名氏.8 小时前
从零手写一个 AI Agent 框架(TypeScript 完整实现):Function Calling 循环、流式输出与错误恢复
人工智能·typescript·node.js·大模型·ai agent·functioncalling·llm 应用开发
关键词安全2 天前
PHP / Node.js / Go / Rust 全部中招(CVE-2026-109618、109619、111497、111943)完整排查与修复清单
golang·rust·node.js
zhensherlock2 天前
Protocol Launcher 系列:CodeHub 移动端 GitHub 协作利器
前端·javascript·typescript·node.js·自动化·github·js
jaysee-sjc2 天前
【黑马点评】Day02:优惠券秒杀与分布式锁
java·分布式·nginx·spring·node.js·tomcat·maven
RobinDevNotes3 天前
24GB Mac 做数字人:声音放本地,画面租云端
人工智能·python·macos·开发工具
ZhengEnCi3 天前
Express 企业级项目结构怎么组织:五层骨架、单向依赖和一份能跑的边界检查脚本
javascript·node.js·express
Dumbness4 天前
搜 platform 却给出 Form 表单:离线文档检索把短关键词当成了子串
javascript·node.js
用户216076340834 天前
一个 2 MB 的 .zst 文件,解压出来只有十几 KB
node.js
oil欧哟5 天前
Oil Studio 的产品思路与日常使用方式:在 Mac 上录口播演示,并接入 AI Agent 精剪与自动录屏
人工智能·macos
木头左6 天前
【浏览器自动化】用 CDP 接管本机 Chrome:从一个宿主迁到另一个宿主的设计与踩坑
node.js·浏览器自动化·cdp·技能化·踩坑实践