Alex
Alex

Reputation: 1583

Yeoman Full-Stack Generator and Nodejitsu deployment

I used Daftmonk's Yeoman Full-stack generator as scaffolding for an app I'm making. I'd like to run it using Nodejitsu's nodejs service. But when I deploy, I get a cascading series of errors, and even once the errors stop in jitsu's cli, the app fails to deploy and gives a file not found.

I'm guessing the errors are coming because on my localhost Grunt is boxing up my app into a dist/ folder where it's being served. And I don't think Nodejitsu is able to account for that.

Has anyone had success deploying on nodejitsu a nodejs app that uses Grunt in this way? Sorry if this question is vague, I'd be happy to elaborate more, but I'm lost!

Upvotes: 0

Views: 154

Answers (1)

Bill Butler
Bill Butler

Reputation: 489

I also use yeoman with Angular Fullstack. It's almost funny how these tools come so close to working but leave you, the developer stuck when it comes to deploying. This isn't actually an answer. It's more of a supportive post acknowledging the problem. Here is what I've discovered.

  • Yeoman likes you to run grunt serve:dist to get a peek at what the minified build will look like. This puts all your production code into /dist/public
  • Nodejitsu will run node server/app.js when it runs
  • Unfortunately, this leaves nodejitsu looking in dist instead of dist/public so it can't find the files

------SEE BELOW FOR A BETTER ANSWER------

I've been playing with this more and as it turns out, the answer is almost too easy, especially with nodejitsu. I'm going to assume that you've already installed the nodejitsu tools with:

[sudo] npm install jitsu -g

I'll also assume you've registered as described here:

https://www.nodejitsu.com/documentation/jitsu/

Now, it's really easy.

  • Run grunt. This will minify and uglify your code. I had some problems with uglify (as many people seem to have) and so I added this to Gruntfile.js to fix the issue. Apparently the js is larger as a result but the headache factor is worth it for me:

Add it within the initConfig section (only take this step if you are getting an error related to loading modules from the console of your browser).

// Uglify Exceptions uglify: { options: { mangle: false } },

Running grunt puts everything into /dist/public.

Now

  • cd /dist
  • jitsu deploy

Everything worked perfectly for me. The key here is being inside the dist dir when you run jitsu deploy. This way, it will only deploy the production compiled code.

Upvotes: 0

Related Questions