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

相关推荐
摇滚侠7 小时前
搭建前端开发环境 安装 nodejs 设置淘宝镜像 最简化最标准版本 不使用 NVM NVM 高版本无法安装低版本 nodejs
java·开发语言·node.js
一招定胜负8 小时前
智慧课堂项目面试复习资料
ide·macos·xcode
小江的记录本8 小时前
【Linux】《Linux常用命令汇总表》
linux·运维·服务器·前端·windows·后端·macos
绝世唐门三哥14 小时前
MacOS下内网穿透工具cpolar使用教程(Mac 版)
macos·内网穿透
jian1105814 小时前
Mac git配置账号和邮箱,可以修改
git·macos
真心喜欢你吖14 小时前
OpenClaw安装部署Mac操作系统版 - 打造你的专属AI助理
java·人工智能·macos·ai·语言模型·智能体·openclaw
tumeng071115 小时前
Node.JS 版本管理工具 Fnm 安装及配置(Windows)
windows·node.js
arvin_xiaoting15 小时前
使用 exo 技术构建 Mac mini AI 推理集群:从架构到实战
人工智能·macos·架构·mac mini·exo
阿正的梦工坊15 小时前
Mac 的.zshrc在 Windows 上等价怎么做:设置环境变量
windows·macos
xrkhy15 小时前
MacOS M3 安装nvm以及node.js
macos·node.js