【发布时间】:2016-05-14 09:38:15
【问题描述】:
我正在尝试编写一个 shell 脚本来自动化我的开发环境设置(安装 python、nvm、node、mongo 等...)。我正在使用 nvm 来安装 Node。它告诉您关闭并重新打开终端以开始使用 nmv 命令。我尝试获取 .bashrc 和 .profile 以使命令立即可用,以便我可以继续使用 nvm install 运行脚本,但它不起作用。
这是我的脚本中与安装 NVM / Node 相关的部分:
#install nvm and latest node version
# sourcing profile and bashrc is not working here. nvm does not execute the next two lines to install node.
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
source ~/.profile
source ~/.bashrc
nvm install 5.0
nvm alias default node
我收到这些消息,但请注意,我已经运行了脚本,并且 NVM / Node 已经安装并正在运行。我还可以在完成后运行脚本的同一终端中使用 nvm 和节点。它只是在脚本中不起作用。
=> Downloading nvm from git to '/home/myDir/.nvm'
=> fatal: destination path '/home/myDir/.nvm' already exists and is not an empty directory.
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
=> Source string already in /home/myDir/.bashrc
=> Close and reopen your terminal to start using nvm
./install-programs.sh: line 27: nvm: command not found
./install-programs.sh: line 28: nvm: command not found
【问题讨论】:
-
在 unix&linux 上有一个等价的问题:unix.stackexchange.com/questions/184508/…