0
votes

I am trying to deploy a node express, react application on aws's ElasticBeanstalk. But the application deployment fails during the npm install on the instance.

Upload Complete. 2018-12-22 20:12:20 INFO Environment update is starting. 2018-12-22 20:12:23 INFO Deploying new version to instance(s). 2018-12-22 20:12:48 ERROR Failed to run npm install. Snapshot logs for more details. 2018-12-22 20:12:50 ERROR [Instance: i-0a7458ff1bef89f9a] 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.14.1-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. 2018-12-22 20:12:50 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. 2018-12-22 20:12:50
ERROR Unsuccessful command execution on instance id(s) 'i-0a7458ff1bef89f9a'. Aborting the operation. 2018-12-22 20:12:50
ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.

package.json
{
  "name": "express-react-boilerplate",
  "version": "1.0.0",
  "description": "boiler plate node + react app",
  "main": "index.js",
  "scripts": {
    "start:dev": "NODE_ENV=dev nodemon node server/app.js",
    "start:test": "NODE_ENV=test node server/app.js",
    "start:prod": "NODE_ENV=prod node server/app.js",
    "format": "prettier es5 --single-quote --write '**/*.js'",
    "format-check": "prettier-check es5 --single-quote --write '**/*.js'",
    "react:watch": "webpack --mode development --watch",
    "react:build": "webpack --mode development",
    "dev-env": "npm-run-all --parallel start:dev react:watch",
    "test:server": "npm run format-check && ava server/tests/* --verbose",
    "test:client": "npm run format-check && ava client/tests/**/*.test.js --verbose",
    "test:client:watch": "npm run format-check && ava client/tests/**/*.test.js --verbose --watch --coverage",
    "test": "npm run format-check && ava */tests/**/*.test.js --verbose",
    "coverage": "nyc npm run test"
  },
  "dependencies": {
    "@babel/cli": "^7.1.5",
    "@babel/core": "^7.1.6",
    "@babel/polyfill": "^7.0.0",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-react": "^7.0.0",
    "@babel/register": "^7.0.0",
    "@callstack/react-theme-provider": "^1.0.7",
    "axios": "^0.18.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-loader": "^8.0.4",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "browser-env": "^3.2.5",
    "chai": "^4.2.0",
    "css-loader": "^1.0.1",
    "dotenv": "^6.1.0",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.7.0",
    "express": "^4.16.4",
    "express-status-monitor": "^1.2.3",
    "node-sass": "^4.10.0",
    "pino": "^5.8.1",
    "pino-pretty": "^2.2.4",
    "prettier": "^1.15.2",
    "prettier-check": "^2.0.0",
    "react": "^16.6.3",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "^16.6.3",
    "react-intl": "^2.7.2",
    "react-redux": "^5.1.1",
    "react-router-dom": "^4.3.1",
    "redux": "^4.0.1",
    "redux-mock-store": "^1.5.3",
    "request": "^2.88.0",
    "sass-loader": "^7.1.0",
    "sinon": "^7.1.1",
    "style-loader": "^0.23.1",
    "supertest": "^3.3.0",
    "webpack": "^4.26.0",
    "webpack-cli": "^3.1.2",
    "whatwg-fetch": "^3.0.0"
  },
  "devDependencies": {
    "ava": "1.0.0-rc.2",
    "create-ava": "^2.0.1",
    "istanbul": "^0.4.5",
    "nodemon": "^1.18.6",
    "npm-run-all": "^4.1.3",
    "nyc": "^13.1.0"
  },
  "ava": {
    "babel": {
      "testOptions": {
        "presets": [
          "@babel/preset-env",
          "@babel/preset-react"
        ]
      }
    },
    "require": [
      "@babel/register",
      "@babel/polyfill",
      "./client/tests/config.js",
      "./client/tests/helpers/browserEnvironment.js"
    ]
  }
}

I can't figure out what's going wrong with the deployment.

The logs say something about python 2 not found but I am not sure if that's the problem. Here are the logs for the reference

------------------------------------- /var/log/eb-activity.log ------------------------------------- gyp verb cli [ '/opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/node', gyp verb cli
'/tmp/deployment/application/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild', gyp verb cli '--verbose', gyp verb cli '--libsass_ext=', gyp verb cli '--libsass_cflags=', gyp verb cli '--libsass_ldflags=', gyp verb cli '--libsass_library=' ] gyp info using [email protected] gyp info using [email protected] | linux | x64 gyp verb command rebuild [] gyp verb command clean [] gyp verb clean removing "build" directory gyp verb command configure [] gyp verb check python checking for Python executable "python2" in the PATH gyp verb which failed Error: not found: python2 gyp verb which failed at getNotFoundError (/tmp/deployment/application/node_modules/which/which.js:13:12) gyp verb which failed at F (/tmp/deployment/application/node_modules/which/which.js:68:19) gyp verb which failed at E (/tmp/deployment/application/node_modules/which/which.js:80:29) gyp verb which failed at /tmp/deployment/application/node_modules/which/which.js:89:16 gyp verb which failed at /tmp/deployment/application/node_modules/isexe/index.js:42:5 gyp verb which failed at /tmp/deployment/application/node_modules/isexe/mode.js:8:5 gyp verb which failed at FSReqWrap.oncomplete (fs.js:154:21) gyp verb which failed python2 { Error: not found: python2 gyp verb which failed at getNotFoundError (/tmp/deployment/application/node_modules/which/which.js:13:12) gyp verb which failed at F (/tmp/deployment/application/node_modules/which/which.js:68:19) gyp verb which failed at E (/tmp/deployment/application/node_modules/which/which.js:80:29) gyp verb which failed at /tmp/deployment/application/node_modules/which/which.js:89:16 gyp verb which failed at /tmp/deployment/application/node_modules/isexe/index.js:42:5 gyp verb which failed at /tmp/deployment/application/node_modules/isexe/mode.js:8:5 gyp verb which failed at FSReqWrap.oncomplete (fs.js:154:21) gyp verb which failed stack: gyp verb which failed 'Error: not found: python2\n at getNotFoundError (/tmp/deployment/application/node_modules/which/which.js:13:12)\n
at F (/tmp/deployment/application/node_modules/which/which.js:68:19)\n at E (/tmp/deployment/application/node_modules/which/which.js:80:29)\n at /tmp/deployment/application/node_modules/which/which.js:89:16\n
at /tmp/deployment/application/node_modules/isexe/index.js:42:5\n
at /tmp/deployment/application/node_modules/isexe/mode.js:8:5\n at FSReqWrap.oncomplete (fs.js:154:21)', gyp verb which failed
code: 'ENOENT' } gyp verb check python checking for Python executable "python" in the PATH gyp verb which succeeded python /usr/bin/python gyp verb check python version /usr/bin/python -c "import sys; print "2.7.15 gyp verb check python version .%s.%s" % sys.version_info[:3];" returned: %j gyp verb get node dir no --target version specified, falling back to host node version: 10.14.1 gyp verb command install [ '10.14.1' ] gyp verb install input version string "10.14.1" gyp verb install installing version: 10.14.1 gyp verb install --ensure was passed, so won't reinstall if already installed gyp verb install version is already installed, need to check "installVersion" gyp verb got "installVersion" 9 gyp verb needs "installVersion" 9 gyp verb install version is good gyp verb get node dir target node version installed: 10.14.1 gyp verb build dir attempting to create "build" dir: /tmp/deployment/application/node_modules/node-sass/build gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/node-sass/build' gyp ERR! System Linux 4.14.77-70.82.amzn1.x86_64 gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/node" "/tmp/deployment/application/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /tmp/deployment/application/node_modules/node-sass gyp ERR! node -v v10.14.1 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok Build failed with error code: 1 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] postinstall: node scripts/build.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] postinstall 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/2018-12-22T20_12_48_626Z-debug.log Running npm install: /opt/elasticbeanstalk/node-install/node-v10.14.1-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 2018/12/22 20:12:48 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 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.14.1-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

[2018-12-22T20:12:48.669Z] INFO [4110] - [Application update app-6694-181222_201205@3/AppDeployStage0/AppDeployPreHook/50npm.sh] : Activity failed. [2018-12-22T20:12:48.669Z] INFO [4110] - [Application update app-6694-181222_201205@3/AppDeployStage0/AppDeployPreHook] : Activity failed. [2018-12-22T20:12:48.669Z] INFO [4110] - [Application update app-6694-181222_201205@3/AppDeployStage0] : Activity failed. [2018-12-22T20:12:48.670Z] INFO [4110] - [Application update app-6694-181222_201205@3] : Completed activity. Result: Application update - Command CMD-AppDeploy failed [2018-12-22T20:17:12.316Z] INFO [4490] - [CMD-TailLogs] : Starting activity... [2018-12-22T20:17:12.316Z] INFO [4490] - [CMD-TailLogs/AddonsBefore] : Starting activity... [2018-12-22T20:17:12.316Z] INFO [4490] - [CMD-TailLogs/AddonsBefore] : Completed activity. [2018-12-22T20:17:12.316Z] INFO [4490] - [CMD-TailLogs/TailLogs] : Starting activity... [2018-12-22T20:17:12.316Z] INFO [4490] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

1

1 Answers

0
votes

It looks like you have a permission problem:

gyp verb build dir attempting to create "build" dir: /tmp/deployment/application/node_modules/node-sass/build gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/node-sass/build' gyp ERR! System Linux 4.14.77-70.82.amzn1.x86_64 gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/node" I'm not sure why that is happening - do you need sudo access?