我正在嘗試編寫一個shell腳本來自動執行我的開發環境設置(安裝python,nvm,node,mongo等)。我正在使用nvm來安裝Node。它告訴您關閉並重新打開您的終端以開始使用nmv命令。我試圖源代碼.bashrc和.profile使命令立即可用,因此我可以繼續使用nvm install運行腳本,但它不起作用。不能在bash腳本中使用nvm
這裏是我的腳本與安裝NVM /節點的段:已安裝
#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 /節點和工作。我也可以在完成之後運行腳本的同一終端中使用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
我把那在我的腳本和瞧,頂部的東西,完美。加入 – Andy
。 〜/ .nvm/nvm.sh之前使用它爲我工作,謝謝! – tylermadison