How can I resolve the “EACCESS: Permission Denied” error when the 50npm.sh hook script fails on my Node.js platform in Elastic Beanstalk?

Last updated: 2020-04-24

The 50npm.sh hook script fails on my Node.js platform in AWS Elastic Beanstalk, and I receive the “EACCESS: Permission Denied” error. How can I resolve this error?

Short Description

The Elastic Beanstalk 50npm.sh hook script fails while installing the packages defined in the package.json file at the root directory of your application source bundle. The hook script is located at /opt/elasticbeanstalk/hooks/appdeploy/pre/ and uses the npm registry to install the required packages in the package.json file. The npm requires root privileges to install these packages, but your Amazon Elastic Compute Cloud (Amazon EC2) instance has only ec2-user privileges that won't allow you to run the hook script.

To resolve this issue, you must change the configuration of the npm registry.

Resolution

1.    Create a file named .npmrc in the root directory of your application source bundle.

2.    In the .npmrc file, set unsafe-perm to true. For example:

unsafe-perm=true

3.    Choose one of the following options:

Create a zip file for your updated application source bundle, and then deploy your application.

--or--

Deploy your application using eb deploy.


Did this article help you?

Anything we could improve?


Need more help?