mapbox / node-pre-gyp

Node.js tool for easy binary deployment of C++ addons
BSD 3-Clause "New" or "Revised" License
1.11k stars 260 forks source link

Installation on EC2 fails with cannot find module '../' #473

Open maciej-blyng opened 5 years ago

maciej-blyng commented 5 years ago

Fails on deployment on AWS Elastic Beanstalk.

[2019-08-11T08:56:26.287Z] INFO  [4116]  : Running 3 of 5 actions: AppDeployPreHook...
c 

  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-v8.16.0-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 ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.

  audited 8561 packages in 7.597s
  found 0 vulnerabilities

  > bcrypt@3.0.6 install /tmp/deployment/application/node_modules/bcrypt
  > node-pre-gyp install --fallback-to-build

  module.js:550
      throw err;
      ^

  Error: Cannot find module '../'
      at Function.Module._resolveFilename (module.js:548:15)
      at Function.Module._load (module.js:475:25)
      at Module.require (module.js:597:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
      at Module._compile (module.js:653:30)
      at Object.Module._extensions..js (module.js:664:10)
      at Module.load (module.js:566:32)
      at tryModuleLoad (module.js:506:12)
      at Function.Module._load (module.js:498:3)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the bcrypt@3.0.6 install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

  npm ERR! A complete log of this run can be found in:
  npm ERR!     /tmp/.npm/_logs/2019-08-11T08_56_45_118Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v8.16.0-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.
  UTC 2019/08/11 08:56:45 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log 

  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-v8.16.0-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

[2019-08-11T08:56:45.136Z] ERROR [4116]  : Command CMD-AppDeploy failed!

Relevant part of the package.json:

  "dependencies": {
    "axios": "^0.19.0",
    "bcrypt": "^3.0.6",
    "body-parser": "^1.18.3",
    "chai": "^4.2.0",
    "express": "^4.16.4",
    "firebase": "^5.8.6",
    "firebase-admin": "~6.0.0",
    "jsonwebtoken": "^8.5.0",
    "mocha": "^6.0.2",
    "shortid": "^2.2.14"
  },
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.3.4",
    "@babel/polyfill": "^7.2.5",
    "@babel/preset-env": "^7.3.4",
    "eslint": "^4.12.0",
    "eslint-plugin-promise": "^3.6.0"
  },
  "private": true
}

Happy to provide more details.

YasharF commented 5 years ago

Most likely your beanstalk instance doesn't have Python 2.x installed which is needed for building bcrypt.

rahulrawal commented 3 years ago

@maciej-blyng: This can be solved by updating bcrypt version 4.0.1.