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?
Looks like I was able to solve this by adding the following to my script files.
Hopefully this can help someone.