1

我正在使用带有“zsh”终端的 Apple M1 Macbook pro,使用“nvm install node”命令安装 Node 时出现问题。在尝试了 nvm 命令后,我直接从https://nodejs.org/en/download/下载了 Node

我想确保节点安装引用目录 NVM 通过 PATH 安装节点。然而,这就是我所看到的。

当我运行命令“哪个节点”时,我得到以下电流输出。我也列出了预期的输出。有没有办法来解决这个问题?

Current output: /usr/local/bin/node
Expected output: /Users/username/.nvm/versions/node/v14.15.4/bin/node
4

1 回答 1

2

如果您仔细查看 nvm 安装说明,您会注意到有关于如何设置更深层次的 shell 集成的信息。

甚至在brew中也注意到了

$ brew info nvm
...
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.

You should create NVM's working directory if it doesn't exist:

  mkdir ~/.nvm

Add the following to /Users/geek/.bash_profile or your desired shell
configuration file:

  export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.

Type `nvm help` for further information.

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

由于您对 zsh 更深层次的 shell 集成感兴趣,请执行此操作(我故意不包含官方文档中的片段,因此它将是最新的)

于 2021-01-16T10:22:31.707 回答