【问题标题】:AWS Elastic Beanstalk run Grunt taskAWS Elastic Beanstalk 运行 Grunt 任务
【发布时间】:2014-06-20 02:11:17
【问题描述】:

我想在弹性 beanstalk 上运行 node.js 应用程序。我有一个客户端,它是通过一项繁重的工作(jade、less、concat 等)构建的。我从 git 中排除了这个文件夹

我可以通过grunt buildClient 在本地运行它,由grunt-cli 执行

我在我的包中添加了gruntgrunt-cli dev-dependencies

我想在应用程序启动之前运行 grunt 构建,我已经在 .ebextensions/app.config 中设置了配置

container_commands:
  01_build_client:
    command: grunt buildClient

我猜我的密码是/tmp/deployment/application/

但有人说Fatal error: Unable to find local grunt。我猜grunt-cli已经安装了,但是为什么会出现这个错误?

我还尝试将 grunt 作业放在 package.jsonpostinstall 部分,但这也不起作用。

如何在 EBS 实例上构建我的繁重作业?

【问题讨论】:

标签: node.js gruntjs amazon-elastic-beanstalk


【解决方案1】:

在 paas 上运行 Grunt 时,最好在项目中本地安装 grunt-cli 和 grunt 的本地副本。这样,它始终可用,并且是您需要的确切版本。然后你运行npm install 而不是grunt 这样你的postinstall 就可以正常工作了。

例如,您的package.json 可能如下所示:

"grunt": "0.4.5",
"grunt-cli": "0.1.13",

【讨论】:

  • postinstall 执行了吗?对我来说似乎没有
  • 据我所知预启动、启动和启动后。
【解决方案2】:

您可以首先使用grunt command 上的--gruntfile <pathToGruntfile> 选项指定gruntfile 的路径。但是,您还需要在运行此之前npm install grunt,否则您将收到相同的错误。

【讨论】:

    【解决方案3】:

    我在尝试将 webpack 捆绑到弹性 beanstalk 上时遇到了类似的问题。我发现当 elastic beanstalk 运行 npm install 时,它包含--production 标志。这意味着您需要将您的开发依赖项移动到依赖项块中。

    让我感到震惊的另一件事是 eb 似乎没有运行 postinstall 脚本,这真的很烦人!我确实发现它运行prestart 脚本。

    我的package.json 文件最终看起来像这样:

    {
      "name": "app",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "node index.js",
        "prestart": "node node_modules/webpack/bin/webpack.js"
      },
      "dependencies": {
        "backbone": "^1.2.1",
        "backbone.marionette": "^2.4.1",
        "webpack": "^1.9.10",
        ...
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2014-05-28
      • 2015-11-16
      • 2019-03-14
      • 2014-12-26
      • 2016-02-13
      • 2015-09-26
      • 2018-05-23
      • 2016-11-28
      • 2014-04-16
      相关资源
      最近更新 更多