Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Beanstalk npm failing

I am trying to upload my app to Elastic Beanstalk but the npm install is failing on node-pre-gyp install --fallback-to-build. I have tried various versions of node with no avail. It seems to be trying to get a package for linux which doesn't exist and is not needed, it is only needed for OSX (in which it is working fine).

The solution seems to be to run npm install with the --no-optional flag but I can't find a way to make EB run install with this flag.

Also this package seems to be a dependency for karma, which I only have as a dev dependency in my package.json file. I can see EB is installing using the --production flag so I don't know what it's trying to install it in the first place.

Any ideas on how to work around this issue would be much appreciated.

>     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 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-v4.6.1-linux-x64/bin/npm',
> '--production', 'rebuild']' returned non-zero exit status 1
> (ElasticBeanstalk::ExternalInvocationError)
>     caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
>       npm WARN package.json [email protected] No repository field.
>       npm WARN package.json [email protected] No README data
>       npm WARN package.json [email protected] No license field.
>       
>       > [email protected] postinstall /tmp/deployment/application/node_modules/uglifyjs-webpack-plugin
>       > node lib/post_install.js
>       
>       
>       > [email protected] install /tmp/deployment/application/node_modules/karma/node_modules/chokidar/node_modules/fsevents
>       > node-pre-gyp install --fallback-to-build
>       
>       node-pre-gyp ERR! Tried to download: https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v46-linux-x64.tar.gz
like image 571
Si-N Avatar asked Mar 13 '17 17:03

Si-N


3 Answers

I got similar kind of error as fallows enter image description here

When I looked at more details section I found this ,where it was an error in the bcrypt library enter image description here

So I removed that library and installed bcryptjs library and deployed it again ,then it was successful deployed. So this kind of errors may appear when there are deprecated libraries and not supportive libraries .

like image 95
Janith Udara Avatar answered Nov 09 '22 14:11

Janith Udara


First, check your log by going to

  1. Go to Elastic Beanstalk.
  2. Click on your app's environment name
  3. Select Logs on the sidebar
  4. Click on Request Logs and select Last 100 Lines or Full Log.
  5. From your log, you will see why npm is failing

Time to fix it!

  1. if it is related to gyp WARN, gyp WARN EACCESS or gyp ERR, then create a file called .npmrc in the root directory of your project. In this file, add unsafe-perm=true. This will force npm to run node-gyp as root.

  2. if the error is related to a particular npm package failing to install, kindly consider an alternative to that package.

All the best !!

like image 35
michael_vons Avatar answered Nov 09 '22 12:11

michael_vons


If anyone else comes across this, my problem was in my .gitignore I had node_modules rather than node_modules/ and the folder was getting tracked and deployed. Removing the node_modules folder from the deployment solved the issue.

like image 38
Si-N Avatar answered Nov 09 '22 12:11

Si-N