找不到AWS CodeDeploy命令 [英] AWS CodeDeploy Command Not Found
问题描述
当尝试部署Node.js应用程序时,在我的 post_install.sh
AfterInstall脚本中收到错误 npm:找不到命令
.超级奇怪的是,在我的BeforeInstall脚本中,我运行 npm install -g pm2
,并且运行正常,没有任何错误.
When trying to deploy a Node.js application I'm getting an error npm: command not found
in my post_install.sh
AfterInstall script. What's super strange is in my BeforeInstall script I run npm install -g pm2
and it works perfectly fine without any errors.
两者都以 ubuntu
用户身份运行.为什么此命令在一个CodeDeploy脚本中起作用而在另一个CodeDeploy脚本中失败?
Both are being run as the ubuntu
user. Why would this command work in one CodeDeploy script and fail in another?
推荐答案
好像我能够通过将以下内容添加到脚本文件中来解决此问题.
Looks like I was able to solve this by adding the following to my script files.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
希望这可以对某人有所帮助.
Hopefully this can help someone.
这篇关于找不到AWS CodeDeploy命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!