我正在运行下面这个简单脚本来测试代码块:
#!/bin/bash
# Load nvm and install latest production node
source $HOME/.nvm/nvm.sh
nvm install v0.10.12
nvm use v0.10.12
如果文件名是test.sh并且使用以上代码,我会得到以下错误:
test.sh: 5: test.sh: source: not found
test.sh: 6: test.sh: nvm: not found
test.sh: 7: test.sh: nvm: not found
根据我在SO上的评论,似乎脚本中的错误源于“==> source: not found”。当我自己在CLI上输入此代码时,代码可以正常工作。由于某种原因,我无法通过shell脚本执行此代码。
任何建议都将不胜感激。