我正在尝试按照这些说明安装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

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


当前回答

假设你已经使用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

其他回答

这对我来说很管用:

在安装nvm之前,请在terminal: touch ~/.bash_profile中运行此命令 之后,在终端中运行: Curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash 重要的……-不要忘记重新启动您的终端或使用命令源~/.nvm/nvm.sh(这将刷新系统路径中的可用命令)。 在终端中,使用命令nvm——version,您应该会看到版本

我最近也遇到了同样的问题,通过使用source ~/.nvm/nvm.sh来获取nvm bash脚本解决了这个问题。

所有这些问题的答案都是有用的。尤其是特拉维斯给出的答案帮助了我。对于Mac OS X用户,我想提供一些步骤,这将帮助他们与节点版本管理器(又名nvm)的新安装。

在Mac OS X上安装和使用nvm

以下是重新安装nvm并毫无问题地使用它的步骤:

Install homebrew from here. Using homebrew install nvm brew update brew install nvm Create .nvm directory at ~/.nvm location. mkdir ~/.nvm Now if you don't have .bash_profile file setup for OS X terminal then please create a .bash_profile at the root level: nano ~/.bash_profile Paste below code in the .bash_profile and press CTRL + O and press enter to save .bash_profile file. Press CTRL + X to exit from editor: export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh Now either quite (CMD + Q) the terminal or run below command to load .bash_profile settings: source ~/.bash_profile Now run nvm ls command to get the list of all installed nodejs versions.

打开终端 如果你有ZSH终端,那么输入命令'open ~/.zshrc' 添加文件结尾,保存如下: ~ / .nvm / nvm.sh来源

首先在~/中添加以下行。bashrc文件(

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

然后打开terminal并源nvm.sh脚本

source ~/.nvm/nvm.sh