Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodeDeploy Command Not Found

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.

Both are being run as the ubuntu user. Why would this command work in one CodeDeploy script and fail in another?

like image 692
Charlie Fish Avatar asked Sep 05 '17 06:09

Charlie Fish


People also ask

How do I know if AWS CodeDeploy is running?

If the CodeDeploy agent is installed and running, you should see a message like The AWS CodeDeploy agent is running .

How do I install CodeDeploy agent on Windows Server?

To install the latest version of the CodeDeploy agent: powershell.exe -Command Read-S3Object -BucketName bucket-name -Key latest/codedeploy-agent. msi -File c:\temp\codedeploy-agent. msi.


1 Answers

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.

like image 74
Charlie Fish Avatar answered Sep 29 '22 09:09

Charlie Fish