Julien
Julien

Reputation: 61

Deploying Sails.js project to Google cloud: "Fatal error: Unable to find local grunt."

I am trying to deploy a sails.js project to Google cloud. After running gcloud preview app deploy app.yaml --set-default, the deploy seems successful but When I browse to my project, all I see is

Error: Server Error

The service you requested is not available yet. Please try again in 30 seconds.

The Logs from console.developers.google.com show "Fatal error: Unable to find local grunt." Should I configure something on Google cloud to have grunt available? Or what should I configure in my project to allow the cloud to find grunt?

I have been able to successfully deploy the demo projects from https://cloud.google.com/nodejs/ but not projects using Sails.js.


UPDATE: SOLVED

The problem was sorted by installing grunt and grunt-cli locally as well as a bunch of other dependencies. Anyone with the same issue can do this:

Make sure the package.json file contains the following dependencies:

"dependencies": {
"express": "^4.12.0",
"gcloud": "^0.15.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-coffee": "^0.13.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-jst": "^0.6.0",
"grunt-contrib-less": "^1.0.1",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-gcloud": "^0.2.0",
"grunt-sails-linker": "^0.10.1",
"grunt-sync": "^0.2.3",
"sails": "^0.11.0",
"sails-disk": "^0.10.8"
}

Then install all dependencies before deploying:

 sudo npm install --save

Upvotes: 1

Views: 303

Answers (1)

Nick
Nick

Reputation: 3591

It's likely that your app is expecting to use Grunt to be able to launch the webserver. A common paradigm with node.js web-apps using Grunt is to run something like grunt serve to start the webserver (something like app.js or bin/www.js). The fact that no webserver is running on your app's container is the reason you see the message you do. Grunt isn't accessible (hence the serve command fails to run) since your Dockerfile didn't install Grunt.

Make your Dockerfile install Grunt. You would install Grunt using npm.

In general, to avoid falling into traps like these, you should learn about the whole stack that runs your web app, even if just in broad outlines, so that identifying failures like this becomes easier.

Upvotes: 2

Related Questions