When I push the code to Github it automatically builds it and start the application on AWS through CodeDeploy with a application_start.sh script file that has the following code:
#!/bin/bash
#give permission for everything in the express-app directory
sudo chmod -R 777 /directory/backend
#navigate into our working directory where we have all our files OR exit
cd /directory/backend || exit
#add npm and node to path
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # loads nvm bash_completion
#install node modules
npm install
npm install pm2@latest -g
#pm2 stop all
pm2 stop backend
pm2 start ecosystem.config.js --env prodaws
127 exit code is "File or Directory Not Found"
I have a nother script that runs before the application_start.sh that installs node, I tried installing a more stable version with nvm install --lt
but it did not change anything even the node verison
The only solution to this is to change the Operating System, Amazon Linux 2 does not upgrade those libraries to the latest version. Changing the OS was also suggested by the Amazon Support team check out this article where I described in detail what happened.