如何使用 .ebextensions 在 Amazon Elastic Beanstalk 中运行 `npm install`

Har*_*son 8 amazon-ec2 amazon-web-services lampp node.js npm

我想使用eb deploy命令在 Amazon Elastic Beanstalk 中部署我的 PHP 应用程序。但是我的应用程序使用 gulp 来连接和缩小 scss 和 js。

所以我在文件中尝试了这些命令 .ebextensios/03npm.config

commands:
  01-install-node:
    command: "yum install nodejs npm --enablerepo=epel -y"

container_commands:
  01-install-dependencies:
    command: "npm install"
  02-build:
    command: "npm run build"
Run Code Online (Sandbox Code Playgroud)

但最后我收到这个错误

[Instance: i-c7800103] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ttps://registry.npmjs.org/acorn npm http 304 https://registry.npmjs.org/amdefine npm http 304 https://registry.npmjs.org/wrappy npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /var/app/ondeck/npm-debug.log npm ERR! not ok code 0. container_command 01-install-dependencies in .ebextensions/03npm.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
Run Code Online (Sandbox Code Playgroud)

我不确定,但似乎npm install从一个可以忽略的包中收到错误,但它正在调度 EB 错误并停止整个过程。

我正在用这台机器运行: 64bit Amazon Linux 2015.09 v2.0.4 running PHP 5.6

有谁知道我们如何解决这个问题?

小智 0

packages:
  yum:
    git: []

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/pre/03_npm_install.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
      cd $EB_APP_STAGING_DIR

      npm install bower
      npm install
      ./node_modules/bower/bin/bower install --allow-root --config.interactive=false
      ./node_modules/grunt-cli/bin/grunt dust
Run Code Online (Sandbox Code Playgroud)