无法执行新的bash NVM [英] Can't execute nvm from new bash

查看:225
本文介绍了无法执行新的bash NVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打开一个新的bash,NVM命令找不到。如此看来,在〜/ .nvm / nvm.sh没有被装上的bash启动。

When I open a new bash, nvm command is not found. It seems that the ~/.nvm/nvm.sh is not being loaded on bash startup.

我已经加入了线下在〜/ .bashrc

I have added the line below to ~/.bashrc

[[ -s /home/$USER/.nvm/nvm.sh ]] && . /home/$USER/.nvm/nvm.sh

任何想法,为什么这是怎么回事?

Any ideas why it is happening?

推荐答案

如果你从一个新的bash实例中运行,并且在你有初始化code你的〜/ .bashrc,〜/ .bash_profile中,等等,那么你需要检查条件语句此初始化文件。

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.

在Ubuntu的14,有一个:

On Ubuntu 14, there is a:

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

在第6行,这将阻止它的执行如果bash不被用-i(互动)标志跑去。所以,你需要运行:

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

这将暂停它的执行,如果未用$ PS1组跑了(就像在一个远程SSH会话)。

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.

希望这是有帮助的。

这篇关于无法执行新的bash NVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆