I've been through several libraries looking for something that I can just deploy to elastic beanstalk and it will "just work", it seems like every library out there fails due to dependencies or some cryptic gyp message that happens as EB does the "npm install"
I really want sharp to work, so I'm willing to spend the time to see if I can get it going. Here is the error that is in the logs after I try to deploy to elastic beanstalk:
1193 info build /tmp/deployment/application/node_modules/sharp
1194 info preinstall [email protected]
1195 info linkStuff [email protected]
1196 silly linkStuff [email protected] has /tmp/deployment/application/node_modules as its parent node_modules
1197 verbose linkBins [email protected]
1198 verbose linkMans [email protected]
1199 verbose rebuildBundles [email protected]
1200 verbose rebuildBundles [ '.bin', 'bluebird', 'color', 'nan', 'request', 'semver', 'tar' ]
1201 info install [email protected]
1202 verbose unsafe-perm in lifecycle false
1203 info [email protected] Failed to exec install script
1204 verbose stack Error: [email protected] install: node-gyp rebuild
1204 verbose stack Exit status 1
1204 verbose stack at EventEmitter.
1204 verbose stack at emitTwo (events.js:87:13)
1204 verbose stack at EventEmitter.emit (events.js:172:7)
1204 verbose stack at ChildProcess.
1204 verbose stack at emitTwo (events.js:87:13)
1204 verbose stack at ChildProcess.emit (events.js:172:7)
1204 verbose stack at maybeClose (internal/child_process.js:818:16)
1204 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
1205 verbose pkgid [email protected]
1206 verbose cwd /tmp/deployment/application
1207 error Linux 4.1.13-19.30.amzn1.x86_64
1208 error argv "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm" "--production" "rebuild"
1209 error node v4.2.3
1210 error npm v2.14.7
1211 error code ELIFECYCLE
1212 error [email protected] install: node-gyp rebuild
1212 error Exit status 1
1213 error Failed at the [email protected] install script 'node-gyp rebuild'.
1213 error This is most likely a problem with the sharp package,
1213 error not with npm itself.
1213 error Tell the author that this fails on your system:
1213 error node-gyp rebuild
1213 error You can get their info via:
1213 error npm owner ls sharp
1213 error There is likely additional logging output above.
1214 verbose exit [ 1, true ]
[email protected] install /tmp/deployment/application/node_modules/sharp
node-gyp rebuild
gyp ERR! clean error
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! stack at Error (native)
gyp ERR! System Linux 4.1.13-19.30.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/sharp
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Linux 4.1.13-19.30.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm" "--production" "rebuild"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/deployment/application/npm-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v4.2.3-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.
Hello, EACCES: permission denied, rmdir 'build' suggests this is a permissions thing.
My best guess is the user that owns the files in /tmp/deployment/application/node_modules is different to the one running the command Running npm install: /opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm.
Perhaps this is a root vs ec2-user thing?
@lovell thanks for getting back to me. I have been trying all sorts of things, but nothing concrete yet on how to fix it. Some good info in these links:
https://github.com/strongloop/fsevents/issues/108
https://forums.aws.amazon.com/thread.jspa?messageID=620673
And some info here about customizing your container, installing packages, and running custom command line commands (if I knew what packages and commands would fix my issue! :)
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-cw.html
It's been a couple of years since I last used Elastic Beanstalk but the "/tmp/deployment/application should probably be owned (recursively) by ec2-user or nodejs for the duration of the staging" comment sounds like it's on the money.
Perhaps run npm install on your application's package.json using another machine (EC2?) first and include the resultant node_modules directory it generates in the zip file you then deploy to Elastic Beanstalk. This might be enough to prevent npm install from trying to update the filesystem at deploy time.
Good luck!
So I worked around it by before doing my "eb deploy" delete everything from node_modules so the server is forced to reinstall everything, when I did that everything deploys fine. Oddly enough I have been using elastic beanstalk for years and never run into this issues.
Thanks again for the help!
Came across this issue after a full day of debugging the same error. Your workaround set me in the right direction so thanks for posting. The real issue ended up being because the .ebignore syntax requires a trailing slash for directories.
.ebignore
node_modules/
Without the trailing slash, your node_modules folder will be uploaded by eb - including all your dev dependencies! Hopefully this helps someone else.
Phew, @jschr ya saved my life. It's working now for me.
Switch to t2.small instead of micro. Mine failed with t1.micro and someone reported the same on t2.micro.
It's a memory issue.
@jschr Thanks!! I too went down the debugging rabbit holes for a day, then found your fix here. Relieved it's such an easy one!
Most helpful comment
Came across this issue after a full day of debugging the same error. Your workaround set me in the right direction so thanks for posting. The real issue ended up being because the .ebignore syntax requires a trailing slash for directories.
.ebignore
Without the trailing slash, your node_modules folder will be uploaded by eb - including all your dev dependencies! Hopefully this helps someone else.