关闭终端不记得我对 nvm/npm 的 .profile 更改

Closing the terminal doesnt remember my .profile changes for nvm/npm

我使用此说明安装了 nvm/npm

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server(如何使用 NVM 安装),但每次我关闭终端时,它似乎忘记了所有设置,我必须执行命令: source ~/.profile 然后 select npm 版本再次 运行 。我怎样才能使我的设置永久保存,或者至少在我的登录会话期间保持不变?谢谢! (linuxmint 17)

采购 ~/.profile

~/.profile 通常从登录 shell 调用。参见 http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files

Invoked as an interactive login shell, or with --login

When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

打开终端通常不会调用登录 shell。你试过rebooting/relogging了吗?此外,如果 ~/.bash_profile~/.bash_login 存在,则 bash 将不会来源 ~/.profile。有两种常见的方法可以解决这个问题:

选项 1

将命令从 ~/.profile 文件移动到 ~/.bash_profile

选项 2

来源 ~/.profile 来自 ~/.bash_profile:

[[ -f ~/.profile ]] && . ~/.profile

默认节点版本

您可以通过将其别名为 default

来配置默认节点版本

To set a default Node version to be used in any new shell, use the alias 'default':

nvm alias default node

https://github.com/creationix/nvm