如何在 Mac 上安装 NVM

Joh*_*doe 4 macos node.js nvm

我尝试使用以下命令在 Mac 上安装 NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Run Code Online (Sandbox Code Playgroud)

但是,我收到一条错误消息:“语法错误接近意外`(”。下面提供了有关错误日志的更多详细信息。我做错了什么?

VFZ:repo2022 john$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4934  100  4934    0     0    686      0  0:00:07  0:00:07 --:--:--   686
bash: line 1: syntax error near unexpected token `('
bash: line 1: `<!-- Copyright (C) 2016 Intel Corporation. All rights reserved. -->'
VFZ:repo2022 john$ 
Run Code Online (Sandbox Code Playgroud)

系统-MAC

小智 8

有一个从终端使用“Rosetta 2”的解决方案:

$ sudo softwareupdate --install-rosetta
Run Code Online (Sandbox Code Playgroud)

使用curl 安装 NVM(可在 NVM 自述文件中找到)

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Run Code Online (Sandbox Code Playgroud)

然后安装任何 Node 版本(示例安装最新版本)

$ nvm install node
Run Code Online (Sandbox Code Playgroud)

检查节点版本

$ node -v
Run Code Online (Sandbox Code Playgroud)

来源:https ://dev.to/httpjunkie/setup-node-version-manager-nvm-on-mac-m1-7kl