1

When trying to deploy node.js application using elastic beanstalk, I am facing some issues. I manually zipped the folder and then deployed that zip file.

    Error: Cannot find module 'node-linux-x64/package.json'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
      at Function.resolve (internal/modules/cjs/helpers.js:33:19)
      at ChildProcess.<anonymous> (/tmp/deployment/application/node_modules/node-bin-setup/index.js:18:27)
      at ChildProcess.emit (events.js:198:13)
      at maybeClose (internal/child_process.js:982:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  npm WARN savingsanalytics-service@1.0.0 No repository field.

     npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! node@10.16.3 preinstall: `node installArchSpecificPackage`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the node@10.16.3 preinstall 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-09-18T00_57_17_598Z-debug.log
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v10.16.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.
  UTC 2019/09/18 00:57:17 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-v10.16.3-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install

  > node@10.16.3 preinstall /tmp/deployment/application/node_modules/node
  > node installArchSpecificPackage

    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-v10.16.3-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)
Jee Mok
  • 4,537
  • 7
  • 35
  • 66
  • Can you provide details on what Instance type you are using as well as the `dependencies` list from your `package.json` – dusthaines Sep 18 '19 at 21:04
  • Please refer the below lines for package.json { "name": "app-service", "version": "1.0.0", "description": "Service", "main": "app.js", "dependencies": { "bcrypt": "^3.0.6", "config": "^3.0.0", "cors": "^2.8.5", "cryptr": "^4.0.2", "express": "^4.16.4", "joi": "^14.3.1", "jsonwebtoken": "^8.4.0", "lodash": "^4.17.11", "node": "^10.16.3", "request": "^2.88.0" }, "devDependencies": {}, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "**********", "license": "ISC" } – Sairam Mamidala Sep 22 '19 at 17:08
  • I am using Elastic Beanstalk to create an instance. This is the instance number provided. [Instance: i-05a17c1a9268fcc68]. – Sairam Mamidala Sep 22 '19 at 17:09
  • you shouldn't need to include `node` in your package because it's already part of the application you've selected via AWS. This might be causing a conflict where you're trying to install node on a machine that already has node installed on it. Try removing this, committing your updated package.json, and deploy again.Also, when I ask about your type I mean the size: t2.small, t3.large, etc. Let me know and I will provide some more help. – dusthaines Sep 23 '19 at 01:38
  • I tried removing nodejs in package.json. I am still facing the same issue. [Instance: i-0353ee559e47fc60a] Command failed on instance. Return code: 1 Output: (TRUNCATED)...opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install raise e subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v10.16.3-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI. **Instance Type**: t2.micro – Sairam Mamidala Sep 25 '19 at 00:42
  • I deployed another service which was successful. This is the package.json for that service.{ "name": "app-service", "version": "1.0.0", "description": "", "main": "app.js", "dependencies": { "config": "^3.2.0", "express": "^4.16.4", "joi": "^14.3.1", "jsonwebtoken": "^8.4.0", "mongoose": "^5.3.14", "mongoose-unique-validator": "^2.0.2" }, "devDependencies": {}, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" } – Sairam Mamidala Sep 25 '19 at 01:12
  • Good to hear. When deploying (especially to small instances) many failures present as one problem but are ultimately the result of something else. I suspect in this case it was a combination of first including `node` in your package, combined with limited memory offered in a `t2.micro` (which is not always freed or reset from one deploy to the next). Creating a new instance will help but does not get at the underlying long term problem of available memory. As you make more progress consider allocating swap memory to help support deploys stackoverflow.com/a/53619081/1720873 – dusthaines Sep 25 '19 at 01:38
  • So, you are saying that this issue is because of memory. The service that got failed is having 521KB, but the service that got successfully deployed had 26.2KB. Because of memory, you are saying that the first service is failing to deploy? – Sairam Mamidala Sep 25 '19 at 04:07
  • Not certain that was the reason, but it's a common enough problem that I thought it would be valuable for you to know about for the future. If you find a similar problem in some weeks or months ahead it would be a good place to investigate and test. Unfortunately the logs and error messages associated with EB are not always good at clearly pointing to the source of a problem. – dusthaines Sep 25 '19 at 05:27
  • I don't think this is memory issue. Because, I deployed a react code by serving it through sample nodejs file which is around 500KB without node_modules. This is working fine. But When I deployed the app-service which is 521KB I am getting the above failure. The difference in memory between react code and app-service code is around 21KB that doesn't make a huge impact I think. Including node modules, React app has 232 MB which is more than the size of app-service which is of size 64.9MB. – Sairam Mamidala Sep 28 '19 at 15:55
  • I analyzed the issue was with **bcrypt** . When I removed bcrypt from package.json, it is working. So, any suggestions on why AWS is not allowing bcrypt? – Sairam Mamidala Sep 29 '19 at 01:32
  • Of course! My apologies for not reviewing your original dependencies list more closely - `bcrypt` can be a real hassle - I've encountered this same issue. One of its dependencies (either `node-gyp` or `node-pre-gyp`) tries to run `mkdir` in the system root to create a `/tmp/…` directory. Since it doesn't have correct permissions it fails. If you must use `bcrypt` you can read more about the issue here: https://github.com/kelektiv/node.bcrypt.js/issues/614 and how to address it in AWS EB here: https://stackoverflow.com/a/46001517/1720873 – dusthaines Sep 30 '19 at 23:24

0 Answers0