AWS Elastic Beanstalk Launches Grunt Task

I want to run the node.js application on an elastic beanstalk. I have a client that is created by rough work (jade, less, concat, etc.). I excluded this folder from git

I can run this locally with grunt buildClient which is executed by grunt-cli

I added grunt and grunt-cli in my dev-dependencies packages

I want to run the grunt build before the application starts, I already configured the configuration in .ebextensions/app.config

 container_commands: 01_build_client: command: grunt buildClient 

I think my cwd /tmp/deployment/application/

but there is Fatal error: Unable to find local grunt . I assume grunt-cli is installed, but why this error?

I also tried to put the grunt job in the postinstall section of package.json , but this does not work either.

How can I build my job on an EBS instance?

+4
elastic-beanstalk gruntjs
source share
3 answers

When running Grunt on paas, it is best to set up a local copy of grunt-cli and shake it locally in the project. Thus, it is always available and is the exact version that you need. Then you run npm install instead of grunt so that your postinstall works correctly.

For example, your package.json might look like this:

 "grunt": "0.4.5", "grunt-cli": "0.1.13", 
+2
source share

First, you can specify the path to your grunt file using the --gruntfile <pathToGruntfile> option on the grunt command . However, you will also need npm install grunt before running this, or you will get the same error.

+1
source share

I just ran into a similar problem trying to get webpack bundilng on an elastic beanstalk. I found that when the elastic beanstalk works with the npm installation, it includes the --production flag. This means that you need to move your dev dependencies to the dependency block.

Something else that caught me was that eb didn't seem to run the postinstall script, which is really annoying! I found that it is running the prestart script.

My package.json file looked something like this:

 { "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", ... } } 
+1
source share

All Articles