找到你要的答案

Q:Node Version Manager install - nvm command not found

Q:节点的版本管理器安装程序命令没有找到

I am trying to install NVM as per these instructions

I typed in this command in terminal:

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

After running the install, I restart the terminal and attempt to install Node.js with this command:

$ nvm install 0.8

but I get the response:

-bash: nvm: command not found

I'm not sure what I am doing wrong here.

Additional Info--

I've been looking around for solutions from other posts and forums. I found another solution using

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

but this times out every time I attempt that. Any help would be appreciated. Thanks.

我试图安装NVM按照这些指示

我在终端输入这个命令:

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

运行安装后,我重新启动终端,试图用这个命令安装Node.js:

$ nvm install 0.8

但我得到了回应:

-bash: nvm: command not found

我不知道我在这里做错了什么。

附加信息:

我一直在寻找其他职位和论坛的解决方案。我找到了另一个解决方案

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

但每次我尝试这一次。任何帮助将不胜感激。谢谢.

answer1: 回答1:

Check your .bash_profile or .profile file. You most likely had a problem during the installation.

You should have the following at the end of one of those files.

[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh  # This loads NVM

The . $HOME/.nvm/nvm.sh is the same as source $HOME/.nvm/nvm.sh

See: Sourcing a File

You can also check to see if you have a .nvm folder.

ls -a | grep .nvm

If you're missing that folder then the installation failed to run the git command. This could be due to being behind a proxy. Try running the following instead.

git clone http://github.com/creationix/nvm.git .nvm

检查您的配置文件。bash_profile或。你最有可能在安装过程中有问题。

在这些文件的结尾处应该有以下内容。

[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh  # This loads NVM

这个.家/美元。NVM / nvm.sh是源家/美元一样。NVM / nvm.sh

参见:采购文件

你也可以检查看看,如果你有一个NVM文件夹。

ls -a | grep .nvm

如果你错过了那个文件夹然后安装运行git命令。这可能是由于背后的代理。尝试运行以下。

git clone http://github.com/creationix/nvm.git .nvm
answer2: 回答2:

I think you missed this step:

source ~/.nvm/nvm.sh

You can run this command on the bash OR you can put it in the file /.bashrc or ~/.profile to automatically load it

https://github.com/creationix/nvm

我想你错过了这一步:

source ~/.nvm/nvm.sh

你可以运行这个命令的bash或者你可以把它放在文件.bashrc或~ /轮廓自动加载它。

https://github.com/creationix/nvm

answer3: 回答3:

source ~/.nvm/nvm.sh Add this line to ~/.bashrc, ~/.profile, or ~/.zshrc

源~ /。NVM / nvm.sh这一行添加到~ / .bashrc,~ /轮廓,或~ / .zshrc

answer4: 回答4:

In macOS, i had to source it using source ~/.nvm/nvm.sh command to fix this problem.

After that, add these lines

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

onto ~/.bash_profile so that nvm will be sourced automatically upon login.

在MacOS,我不得不源使用源~ /。NVM / nvm.sh命令来解决这个问题。

之后,添加这些行

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

在~ /。bash_profile使NVM将源时自动登录。

answer5: 回答5:

Not directly connected to the question, but there is a similar problem that may happen, take a look at this question: Can't execute nvm from new bash


Here's my answer on that post, just for the reference:

If you are running from a new bash instance, and you HAVE the initialization code at your ~/.bashrc, ~/.bash_profile, etc, then you need to check this initialization file for conditionals.

On Ubuntu 14, there is a:

case $- in
    *i*) ;;
      *) return;;
esac

At line 6, that will halt it's execution if bash is not being ran with the "-i" (interactive) flag. So you would need to run:

bash -i

Also, at the end of the file, there is a

[ -z "$PS1" ] && return

That will halt it's execution if not being ran with $PS1 set (like on a remote ssh session).

If you do not wish to add any env vars or flags, you will need to remove those conditionals from your initialization file.

Hope that's helpful.

不直接相连的问题,但也存在类似的问题,可能会发生,去看待这一问题:不能从新的bash执行NVM


这是我在那篇文章上的回答,只是为了参考:

如果你是从一个新的攻击实例运行,和你的初始化代码在你的~ / .bashrc,~ /。bash_profile,等等,那么你需要检查这个初始化文件的条件。

在Ubuntu 14中,有一个:

case $- in
    *i*) ;;
      *) return;;
esac

在6号线,如果bash不是跑“我”停止它的执行(互动)的旗帜。所以你需要运行:

bash -i

此外,在文件的结尾,有一个

[ -z "$PS1" ] && return

那如果不跑1美元停止它的执行(如设置在远程SSH会话)。

如果你不想添加任何env vars或标志,你需要从你的初始化文件中删除这些条件。

希望有帮助。

answer6: 回答6:

If you are using OS X, you might have to create your .bash_profile file before running the installation command. That did it for me.

Create the profile file

touch ~/.bash_profile

Re-run the install and you'll see a relevant line in the output this time.

=> Appending source string to /Users/{username}/.bash_profile

Reload your profile (or close/re-open the Terminal window).

.  ~/.bash_profile

如果你使用的是Mac OS X,你可以建立你的。bash_profile文件运行安装命令之前。那是为我做的。

创建配置文件

touch ~/.bash_profile

重新运行安装,你会看到一个相关的输出在这一次。

= & gt;添加源字符串/用户/ {用户名} /。bash_profile

重新加载您的配置文件(或关闭/重新打开终端窗口)。

.  ~/.bash_profile
node.js  terminal  nvm