I'm trying to upload my NodeJS app into Elastic Beanstalk in Amazon AWS. But when npm install is executed it rises some permission denied and so it's unable to run the app. This is the log
Application update failed at 2018-10-02T15:18:14Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed.
+ /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
npm WARN deprecated [email protected]: ⚠️ WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
npm WARN deprecated [email protected]: Use mz or fs-extra^3.0 with Promise Support
> [email protected] preinstall /tmp/deployment/application/node_modules/scrypt
> node node-scrypt-preinstall.js
Error: Error: Command failed: ./configure
./configure: line 1904: config.log: Permission denied
./configure: line 1914: config.log: Permission denied
> [email protected] install /tmp/deployment/application/node_modules/keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."
> [email protected] rebuild /tmp/deployment/application/node_modules/keccak
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/keccak/build'
gyp ERR! System Linux 4.14.67-66.56.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/keccak
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
┌──────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /tmp/.config │
└──────────────────────────────────────────────────┘
Keccak bindings compilation fail. Pure JS implementation will be used.
> [email protected] install /tmp/deployment/application/node_modules/scrypt
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/scrypt/build'
gyp ERR! System Linux 4.14.67-66.56.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/scrypt
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/.npm/_logs/2018-10-02T15_18_14_229Z-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/bin/npm
Setting npm config jobs to 1
npm config jobs set to 1
Running npm with --production flag
Failed to run npm install. Snapshot logs for more details.
UTC 2018/10/02 15:18:14 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log
Traceback (most recent call last):
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
main()
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
node_version_manager.run_npm_install(options.app_path)
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
raise e
subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.11.4-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1.
Incorrect application version "nodecms_0.1.0" (deployment 3). Expected version "nodecms-0.1.0" (deployment 1).
I've looked for some solutions but no one has worked. I've also add this script in .ebextensions/00_change_npm_permissions.config to add root permission but has no effects.
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp
I'm new in Amazon AWS hoping that someone could help me to fix this problem.
I've tried also to put .npmrc file with unsafe-perm=true in the root of the NodeJS project (As described here: Beanstalk: Node.js deployment - node-gyp fails due to permission denied) but the problem persists
Elastic Beanstalk provides platforms for programming languages (Go, Java, Node. js, PHP, Python, Ruby), application servers (Tomcat, Passenger, Puma), and Docker containers.
Elastic Beanstalk isn't great if you need a lot of environment variables. The simple reason is that Elastic Beanstalk has a hard limit of 4KB to store all key-value pairs. The environment had accumulated 74 environment variables — a few of them had exceedingly verbose names.
So after trying everything the only solution that worked was to add an environment properties into Beanstalk console:
NPM_CONFIG_UNSAFE_PERM = true
Together with my previous attempt, EC2 was finally able to deploy my NodeJS project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With