NPM issue deploying a nodejs instance using AWS codedeploy

余生颓废 提交于 2019-12-05 02:51:18

As accurately noted in the comments by mbaird and Chris - it was that I didn't have my PATH set. So npm, and node, and pm2 and... all failed.

Through experimentation, it appeared I needed to reestablish my path with every step of the Codedeploy deploy process. So at the top of my stop.sh/beforeinstall.sh/afterinstall.sh/start.sh, I included:

source /home/ec2-user/.bash_profile

and life was good. I then ran into other issues with pm2 not starting node in the right working directory, but similar tweaking to the codedeploy scripts got that working.

This was all obvious in hindsight, but I'm extremely grateful for the help. Thank you guys!

The host agent uses roots fairly stripped down environment. An exit code of 127 indicates that the OS can't find some file it needs to load the script (it could be the script of something that is needed to execute it).

The best thing to do is make sure npm is installed for root.

Since, the host agent sources /etc/profile when launched as a service, you can also add anything you need to get npm working there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!