我正在尝试按照这些说明安装NVM

我在终端输入了这个命令:

$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh

运行install后,重启终端并尝试使用以下命令安装Node.js:

$ nvm install 0.8

但我得到的回答是:

-bash: nvm: command not found

我不知道我哪里做错了。

额外的信息,

我一直在其他帖子和论坛中寻找解决方案。我找到了另一个解决办法

$ git clone git://github.com/creationix/nvm.git ~/.nvm

但是每次我尝试的时候,这个就会超时。任何帮助都将不胜感激。谢谢。


当前回答

对于Mac OS:

打开终端 运行touch ~/.bash_profile 执行vi ~/.bash_profile命令 输入source ~/.nvm/nvm.sh 按Shift + Esc键,输入wq,按enter键 完成了。

其他回答

假设你已经使用brew安装了nvm(我在mac上),我的意思是像brew安装nvm这样的东西,你所需要做的就是:

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

  mkdir ~/.nvm

 2. Add the following to ~/.zshrc 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

使用以下代码

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash`
source ~/.nvm/nvm.sh`
nvm install 0.8

我在MacBook Pro上安装nvm时也遇到过类似的问题。

我最初使用brew安装了nvm:

brew install nvm

但是当我运行命令时:

nvm --version

我得到了错误:

ZSH nvm: command not found .输出说明

以下是我的解决方法:

使用brew安装nvm还不足以让它工作。你还需要做以下事情;

Confirm that the source ~/.zshrc, ~/.bash_profile, ~/.profile, or ~/.bashrc file exists: zsh: ~/.zshrc bash: ~/.bashrc ksh: ~/.profile Else create it using: touch ~/.zshrc touch ~/.bashrc touch ~/.profile Next, run either of the commands below: Note: You can check the referenced link below to get the updated commands. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash OR wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash Note: Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc) 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" # This loads nvm.

您可以检查下面引用的链接以获得更新后的脚本。

参考:安装和更新NVM

在尝试了多个步骤后,不确定我的情况下有什么问题,但运行这个方法有帮助:

touch ~/.bash_profile
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

由nvm——version验证

MacOS;

在终端>上运行

open ~/.bash_profile

粘贴所有这些=

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm