3

I am try to install a simple Node.js application on Elastic Beanstalk using the command line tools.

On my git repository I run the command

$ eb deploy

to deploy the contents of my git repository. It deploys fine however the Health status of the application is Red.

If I look at the logs on the Elastic Beanstalk website, it points me to the following error in the logs:

> fsevents@1.0.8 install /tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents/build'
gyp ERR! stack at Error (native)
gyp ERR! System Linux 4.1.17-22.30.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-linux-x64/fse.node" "--module_name=fse" "--module_path=/tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-linux-x64"
gyp ERR! cwd /tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v4.3.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 

I tried various things like:

  1. Creating the directory myself (the directories are owned by root).
  2. Deleting everything from /tmp so that hopefully next time it fixes itself.
  3. Deleting my node_modules directory.

None of these options work and I can't find a workaround or a reason why this happens. I can run the node.js app locally as well as deploy it to Azure and Heroku without any issues.

Kostub Deshmukh
  • 2,571
  • 1
  • 21
  • 35
  • I have this same issue, did you find anything out? The proposed answer wasn't my issue – ParoX Jun 20 '16 at 04:11
  • I have figured it out, a module was trying to install another module using `npm install` in the `preinstall` section of their package.json. Hopefully that is your issue too. – ParoX Jun 21 '16 at 03:52
  • I fixed my issue by not checking in `node_modules` in the git repository. `npm install` automatically creates them. – Kostub Deshmukh Jun 21 '16 at 10:10

2 Answers2

6

I had a similar problem but wasn't using eb to deploy and did not include node_modules/ in the package. The solution that worked for me was to set unsafe-perm=true in .npmrc - see Beanstalk: Node.js deployment - node-gyp fails due to permission denied

Jakub Holý
  • 5,295
  • 2
  • 26
  • 31
5

Spent an entire day debugging this error. Turns out you need a trailing slash for directories in your .ebignore file.

.ebignore

node_modules/

Without the trailing slash, your local node_modules folder will be uploaded by eb - including dev dependencies.

jschr
  • 1,726
  • 1
  • 15
  • 21
  • 4
    It is preferable to add `node_modules` to your `.gitignore` file. That solves this issue. – Kostub Deshmukh Jun 21 '16 at 10:10
  • 1
    You're correct - that will also solve the issue. I had a `.gitignore` but needed a separate `.ebignore` in order to upload some build files that are also in `.gitignore`. The docs claim that `.ebignore` follows the same syntax as `.gitignore` but this isn't exactly true – jschr Jun 21 '16 at 16:31