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
I got similar kind of error as fallows
When I looked at more details section I found this ,where it was an error in the bcrypt
library
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 .
First, check your log by going to
Elastic Beanstalk.
Logs
on the sidebarRequest Logs
and select Last 100 Lines
or Full Log.
Time to fix it!
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.
if the error is related to a particular npm package failing to install, kindly consider an alternative to that package.
All the best !!
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.
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