npm install on aws ec2 instance throw EACCES


I’ve created a pre-configured node.js instance on AWS using ElasticBeanstalk, but the application does not run correctly. SO I connected to the instance and found out there is no node or angular cli, so I installed them manually. I then tried to run npm install in the application folder but failed, here is the output error.

I already installed node using version manager nvm, and tried also chown permission to nodejs:

I appreciate if someone could help me resolve this problem,


It’s a LINUX permissions issue, your ec2-user doesn’t have write permissions in that directory.

I faced the same issue recently and my workaround was the following:

Note that I’m not an expert in UNIX neither AWS so maybe there is a better/cleaner/easier solution to this issue.

Having node and npm installed globally:

Log as root user using: sudo su and run npm install

Having node and npm only installed in ec2-user:

  • Log as root user using: sudo su
  • Create a group of users: sudo groupadd mygroup
  • Now that the group exists, add users to it:

  • Now all that’s left is to set the permissions on the directory:

  • Now you can exit as root user: exit and run npm install as ec2-user

Leave a Reply