/usr/bin/env: node: Permission denied for nodejs using AWS Code Deploy

3,706 views
Skip to first unread message

Dheeraj Batra

unread,
Jul 20, 2016, 10:46:27 AM7/20/16
to nodejs

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:

  1. Why am I getting 'node: permission denied' error?
  2. 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


Disclaimer :-

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail and destroy all copies of this message and any attachments. Any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. 

Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.

Thales Dias

unread,
Apr 9, 2017, 3:02:00 PM4/9/17
to nodejs
Thaks!!!
I has a problem with my aurelia app.
Your commnt about "paths to bashrc" helped me.

Thank you!!!
Reply all
Reply to author
Forward
0 new messages