AWS Elastic Beanstalk 运行 Grunt 任务

pfr*_*ied 5 node.js gruntjs amazon-elastic-beanstalk

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

我可以在本地运行它,grunt buildClient其执行方式是grunt-cli

我在我的包中添加了gruntgrunt-clidev-dependencies

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

container_commands:
  01_build_client:
    command: grunt buildClient
Run Code Online (Sandbox Code Playgroud)

我想我的cwd是/tmp/deployment/application/

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

我也尝试将繁重的工作放在 的postinstall部分中package.json,但这也不起作用。

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

Saw*_*oes 2

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

例如,你的package.json可能看起来像这样:

"grunt": "0.4.5",
"grunt-cli": "0.1.13",
Run Code Online (Sandbox Code Playgroud)