I wrote a script for deploying code to EC2 instance using AWS Code Deploy, my files are getting copied to the destination, then my hooks run, remove commands, cd commands are running fine but when the following command is run:
/usr/bin/node/bin/forever start /home/ubuntu/codebase/app/bin/www
I get the following error and deployment fails:
/usr/bin/env: node: Permission denied
I have setup the node version v4.4.0 by downloading using wget and then adding following paths to bashrc:
export NODEJS_HOME=/usr/share/nodejs/bin
export PATH=$PATH:$NODEJS_HOME
I also added a symlink:
sudo ln -s /usr/share/nodejs/
My appspec.yml hooks:
ApplicationStart:
- location: scripts/start_server.sh
timeout: 30
runas: ubuntu
Questions:
- Why am I getting 'node: permission denied' error?
- Secondly, Why I need to give the full path for 'npm, node, forever'?
If I go to the corresponding directory: /opt/codedeploy-agent/deployment-root/..... and then run my script manually as an Ubuntu user, it works fine. Although running it as sudo, gives the same error on console