如何在 Mac 上安装 NVM

3

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

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

但是,我遇到了一个错误,错误信息为:"syntax error near unexpected `("。有关错误日志的更多详细信息请参见下面。我做错了什么?

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$ 

系统 - MAC

3个回答

7

有一个使用 'Rosetta 2' 的解决方案。

从终端输入:

$ sudo softwareupdate --install-rosetta

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

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

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

$ nvm install node

检查 Node 版本

$ node -v

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

这篇文章介绍如何在Mac M1上设置Node版本管理器(NVM)。

0

Homebrew(brew)使安装和管理nvm的版本变得轻松。 如果您已经安装了Homebrew,请运行brew install nvm。然后您就可以开始使用了。


0
如果curl无法工作,您可以使用wget,但是您需要安装wget,您可以使用homebrew进行安装。
``` brew install wget ```
然后运行以下命令:
``` wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash ```
安装程序将自动更新配置文件,但如果没有,请手动更新如下:
首先确定您正在使用哪个shell:
``` echo $0 ```
如果是zsh,请更新`~/.zprofile`文件;如果是bash,请更新`~/.bash_profile`文件,并添加以下行:
``` export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" ```

之后,如果您使用的是bash,请运行source ~/.bashrc,或者如果您使用的是zsh,请运行source ~/.zprofile,然后您就可以使用NVM了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接