Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with Node v4.2.3 #108

Closed
onury opened this issue Jan 7, 2016 · 11 comments
Closed

Does not work with Node v4.2.3 #108

onury opened this issue Jan 7, 2016 · 11 comments

Comments

@onury
Copy link

onury commented Jan 7, 2016

gyp ERR! cwd /tmp/deployment/application/node_modules/forever-monitor/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok. 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":[{"msg":"Failed to run npm install. Snapshot logs for more details.","severity":"ERROR","timestamp":1452147841151}]}],"truncated":"true"}
[2016-01-07T06:24:01.184Z] Command return code 1.
[2016-01-07T06:24:01.188Z] Tailing /var/log/eb-commandprocessor.log

******************* eb-commandprocessor taillog *******************
  npm ERR! fsevents@1.0.6 install: `node-pre-gyp install --fallback-to-build`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the fsevents@1.0.6 install script 'node-pre-gyp install --fallback-to-build'.
  npm ERR! This is most likely a problem with the fsevents package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     node-pre-gyp install --fallback-to-build
  npm ERR! You can get their info via:
  npm ERR!     npm owner ls fsevents
  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.
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 681, in <module>
      main()
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 663, in main
      node_version_manager.run_npm_install(options.app_path)
    File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 131, 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 166, in npm_install
      raise e
  subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 1
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/forever-monitor/node_modules/chokidar/node_modules/fsevents/build'
  gyp ERR! stack     at Error (native)
  gyp ERR! System Linux 4.1.13-18.26.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" "configure" "--fallback-to-build" "--module=/tmp/deployment/application/node_modules/forever-monitor/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/forever-monitor/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-linux-x64"
  gyp ERR! cwd /tmp/deployment/application/node_modules/forever-monitor/node_modules/chokidar/node_modules/fsevents
  gyp ERR! node -v v4.2.3
  gyp ERR! node-gyp -v v3.0.3
Jan  7 06:24:01 ip-172-31-47-105 [eb-cfn-init]:   gyp ERR! not ok  (Executor::NonZeroExitStatus)
@bnoordhuis
Copy link
Contributor

That looks like an issue with elastic beanstalk, not node or fsevents. You need to fix the EACCES error somehow.

@onury
Copy link
Author

onury commented Jan 8, 2016

Hi, that was also my thought but here is the response I got from AWS tech support:

The package is trying to create a folder under tmp which anyone can write to but if you are creating sub directories you need the -P switch.
Here are the perms to the tmp folder drwxrwxrwt 6 root root 4096 ('t' is the sticky bit https://en.wikipedia.org/wiki/Sticky_bit)

Your Reported error:
stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/forever-monitor/node_modules/chokidar/node_modules/fsevents/build'

I was able to run the same command on the instance as mkdir -P /tmp/deployment/application/node_modules/forever-monitor/node_modules/chokidar/node_modules/fsevents/build and this worked fine.

So to get around EACCES: permission denied the lines in the package needs to be modified with -P switch.

@bnoordhuis
Copy link
Contributor

I kind of doubt that's it (and I assume you mean -p, I don't think mkdir has a -P flag.) node-gyp creates directories recursively using the mkdirp package.

@yzdong
Copy link

yzdong commented Jan 29, 2016

I'm facing the same issues with AWS-- seems like a temporary solution can be found here.

@kostub
Copy link

kostub commented Mar 22, 2016

I had the same issue with the dependency coming from the nodemon module. After uninstalling nodemon it worked fine. See issue. Maybe you have the same issue with the forever-monitor.

@unreal0
Copy link

unreal0 commented May 19, 2016

npm config set unsafe-perm true

@jschr
Copy link

jschr commented Jun 17, 2016

Posting in hopes to spare someone else the grief of debugging this error. The issue was fixed for me by adding a trailing slash to the node_modules folder in .ebignore

.ebignore

node_modules/

Without the trailing slash, eb will upload your local node_modules folder - dev dependencies and all.

@holyjak
Copy link

holyjak commented Sep 1, 2017

Thanks a lot, @unreal0 ! Your solution helped me (contrary to others). I have made it easier to find via SO: https://stackoverflow.com/questions/46001516/beanstalk-node-js-deployment-node-gyp-fails-due-to-permission-denied/46001517#46001517

@akashgangrade
Copy link

Add a file named .npmrc to the application with the content:

unsafe-perm=true
Now use the following command before pushing it to ElasticBeanStalk:

    git add .npmrc
    git commit -m"EB issue fix"

Now deploy your code. It should work.

@eybel
Copy link

eybel commented May 13, 2022

Hi guys I followed the steps to upload a Backend Express.js app with Beanstalk but I keep getting same error... What else could it be?

I have the .npmrc file in my app with:

unsafe-perm=true

2022/05/13 22:27:42.576234 [ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/sh -c npm --production install failed with error exit status 1. Stderr:npm ERR! code 1
npm ERR! path /var/app/staging/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: EACCES: permission denied, mkdir '/root/.npm'

@rsokalski
Copy link

I think it depends on the version of npm. From the logs I can see that unsafe-perm works only <= 6 npm version.

2022-09-15T12:13:52.569+02:00 | npm ERR! sharp: - For npm <= v6, try again with the "--unsafe-perm" flag
2022-09-15T12:13:52.569+02:00 | npm ERR! sharp: - For npm >= v8, the user must own the directory "npm install" is run in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests