AWS ElasticBeanstalk节点部署无法运行npm install。快照日志以获取更多详细信息

时间:2018-12-22 20:21:38

标签: node.js amazon-web-services express devops amazon-elastic-beanstalk

我正在尝试在AWS的ElasticBeanstalk上部署节点快速响应的应用程序。但是在实例上的npm安装期间,应用程序部署失败。

  

上传完成。 2018-12-22 20:12:20 INFO环境更新为   开始。 2018-12-22 20:12:23 INFO部署新版本   到实例。 2018-12-22 20:12:48错误无法运行npm   安装。快照日志以获取更多详细信息。 2018-12-22 20:12:50错误   [实例:i-0a7458ff1bef89f9a]命令在实例上失败。返回   代码:1输出:   (已截断)... opt / elasticbeanstalk / containerfiles / ebnode.py”,行   180,在npm_install中       提高e subprocess.CalledProcessError:命令'['/opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/npm',   '--production','install']'返回非零退出状态1.挂钩   /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh失败。欲了解更多   详细信息,请使用控制台或EB CLI检查/var/log/eb-activity.log。   2018-12-22 20:12:50 INFO命令执行已全部完成   实例。摘要:[成功:0,失败:1]。 2018-12-22 20:12:50
  错误在实例ID上命令执行失败   'i-0a7458ff1bef89f9a'。中止操作。 2018-12-22 20:12:50
  错误无法部署应用程序。
                                                                         错误:ServiceError-无法部署应用程序。

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"
    ]
  }
}

我无法弄清楚部署出了什么问题。

日志显示未找到有关python 2的信息,但我不确定这是否是问题。这是参考日志

  

------------------------------------- /var/log/eb-activity.log   ------------------------------------- gyp动词cli ['/ opt / elasticbeanstalk / node-install /node-v10.14.1-linux-x64/bin/node',   gyp动词cli
  '/tmp/deployment/application/node_modules/node-gyp/bin/node-gyp.js',
  gyp动词cli'rebuild',gyp动词cli'--verbose',gyp动词cli   '--libsass_ext =',gyp动词cli'--libsass_cflags =',gyp动词cli   '--libsass_ldflags =',gyp动词cli'--libsass_library ='] gyp   信息使用node-gyp@3.8.0 gyp信息使用node@10.14.1 | linux | x64   gyp动词命令重建[] gyp动词命令干净[] gyp动词   干净地删除“ build”目录gyp verb命令configure [] gyp   动词检查python在PATH中检查Python可执行文件“ python2”   gyp动词which失败错误:找不到:python2 gyp动词which   在getNotFoundError失败   (/tmp/deployment/application/node_modules/which/which.js:13:12)gyp   动词which在F处失败   (/tmp/deployment/application/node_modules/which/which.js:68:19)gyp   动词which在E处失败   (/tmp/deployment/application/node_modules/which/which.js:80:29)gyp   动词which在   /tmp/deployment/application/node_modules/which/which.js:89:16 gyp   动词which在   /tmp/deployment/application/node_modules/isexe/index.js:42:5 gyp   动词which在   /tmp/deployment/application/node_modules/isexe/mode.js:8:5 gyp动词   which在FSReqWrap.oncomplete(fs.js:154:21)gyp动词上失败   which python2失败{错误:找不到:python2 gyp动词which   在getNotFoundError失败   (/tmp/deployment/application/node_modules/which/which.js:13:12)gyp   动词which在F处失败   (/tmp/deployment/application/node_modules/which/which.js:68:19)gyp   动词which在E处失败   (/tmp/deployment/application/node_modules/which/which.js:80:29)gyp   动词which在   /tmp/deployment/application/node_modules/which/which.js:89:16 gyp   动词which在   /tmp/deployment/application/node_modules/isexe/index.js:42:5 gyp   动词which在   /tmp/deployment/application/node_modules/isexe/mode.js:8:5 gyp动词   which在FSReqWrap.oncomplete(fs.js:154:21)gyp动词上失败   which失败的堆栈:gyp动词which失败'错误:否   找到:python2 \ n在getNotFoundError   (/tmp/deployment/application/node_modules/which/which.js:13:12)\n
  在F(/tmp/deployment/application/node_modules/which/which.js:68:19)\n   在E(/tmp/deployment/application/node_modules/which/which.js:80:29)\n   在/tmp/deployment/application/node_modules/which/which.js:89:16\n
  在/tmp/deployment/application/node_modules/isexe/index.js:42:5\n
  在/tmp/deployment/application/node_modules/isexe/mode.js:8:5\n在   FSReqWrap.oncomplete(fs.js:154:21)',gyp动词which失败
  代码:“ ENOENT”} gyp动词检查python检查Python   PATH gyp动词which中的可执行文件“ python”继承了python   / usr / bin / python gyp动词检查python版本/usr/bin/python -c "import sys; print "2.7.15 gyp verb check python version .%s.%s" % sys.version_info[:3];"返回:%j gyp动词get node dir no   --target版本指定,回退到主机节点版本:10.14.1 gyp verb命令install ['10 .14.1'] gyp verb install输入   版本字符串“ 10.14.1” gyp动词install安装版本:   10.14.1 gyp动词安装-确保已通过,因此如果已经安装了gyp动词安装版本,则不会重新安装,   需要检查“ installVersion” gyp动词是否获得“ installVersion” 9 gyp   动词需要“ installVersion” 9 gyp动词安装版本是好的gyp   动词获取节点目录安装的目标节点版本:10.14.1 gyp动词   尝试创建“构建”目录的构建目录:   / tmp / deployment / application / node_modules / node-sass / build gyp ERR!   配置错误gyp ERR!堆栈错误:EACCES:权限被拒绝,   mkdir'/ tmp /部署/应用程序/ node_modules / node-sass / build'gyp   呃!系统Linux 4.14.77-70.82.amzn1.x86_64 gyp ERR!命令   “ /opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/node”   “ / tmp /部署/应用程序/node_modules/node-gyp/bin/node-gyp.js”   “重建”“ --verbose”“ --libsass_ext =”“ --libsass_cflags =”   “ --libsass_ldflags =”“ --libsass_library =” gyp错误!电脑   / tmp / deployment / application / node_modules / node-sass gyp错误!节点-v   v10.14.1 gyp错误! node-gyp -v v3.8.0 gyp错误!不好Build   失败,错误代码:1 npm警告可选的跳过选项   相关性:fsevents@1.2.4(node_modules / fsevents):npm WARN notsup   跳过可选依赖项:fsevents@1.2.4不受支持的平台:   通缉{“ os”:“ darwin”,“ arch”:“ any”}(当前:   {“ os”:“ linux”,“ arch”:“ x64”})        npm ERR!代码ELIFECYCLE npm ERR! errno 1 npm错误! node-sass@4.10.0安装后:node scripts/build.js npm ERR!出口   状态1 npm错误! npm ERR!在node-sass@4.10.0处失败   安装后脚本。 npm ERR!这可能不是问题   npm。上面可能还有其他日志记录输出。        npm ERR!可以在以下位置找到该运行的完整日志:npm ERR! /tmp/.npm/_logs/2018-12-22T20_12_48_626Z-debug.log运行npm   安装:   /opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/npm
  将npm配置作业设置为1 npm配置作业设置为1运行npm   使用--production标志时,无法运行npm install。的快照日志   更多细节。 UTC 2018/12/22 20:12:48找不到应用程序npm   调试日志位于/tmp/deployment/application/npm-debug.log        追溯(最近一次通话):       文件“ /opt/elasticbeanstalk/containerfiles/ebnode.py”,行695,在         主要()       主目录中的文件“ /opt/elasticbeanstalk/containerfiles/ebnode.py”,行677         node_version_manager.run_npm_install(options.app_path)       在run_npm_install中的文件“ /opt/elasticbeanstalk/containerfiles/ebnode.py”,第136行         self.npm_install(bin_path,self.config_manager.get_container_config('app_staging_dir'))       npm_install中的文件“ /opt/elasticbeanstalk/containerfiles/ebnode.py”,第180行         提高e subprocess.CalledProcessError:命令'['/opt/elasticbeanstalk/node-install/node-v10.14.1-linux-x64/bin/npm',   '--production','install']'返回非零退出状态1   (执行人:: NonZeroExitStatus)

     

[2018-12-22T20:12:48.669Z]信息[4110]-[应用程序更新   app-6694-181222_201205@3/AppDeployStage0/AppDeployPreHook/50npm.sh]:   活动失败。 [2018-12-22T20:12:48.669Z]信息[4110]-   [应用程序更新   app-6694-181222_201205 @ 3 / AppDeployStage0 / AppDeployPreHook]:活动   失败了[2018-12-22T20:12:48.669Z]信息[4110]-[应用程序更新   app-6694-181222_201205 @ 3 / AppDeployStage0]:活动失败。   [2018-12-22T20:12:48.670Z]信息[4110]-[应用程序更新   app-6694-181222_201205 @ 3]:完成的活动。结果:申请   更新-命令CMD-AppDeploy失败[2018-12-22T20:17:12.316Z]信息   [4490]-[CMD-TailLogs]:开始活动...   [2018-12-22T20:17:12.316Z]信息[4490]-[之前的CMD-TailLogs / Addons]   :开始活动... [2018-12-22T20:17:12.316Z]信息[4490]-   [CMD-TailLogs / AddonsBefore]:已完成的活动。   [2018-12-22T20:17:12.316Z]信息[4490]-[CMD-TailLogs / TailLogs]:   正在开始活动... [2018-12-22T20:17:12.316Z]信息[4490]-   [CMD-TailLogs / TailLogs / TailLogs]:正在开始活动...

1 个答案:

答案 0 :(得分:0)

您似乎有权限问题:

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" 我不确定为什么会这样-您是否需要sudo访问权限?