Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy nodejs & express to parse.com?

I've developed a web app on nodejs with express as framework and jade as templating engine with the aim to deploy it to parse.com. Everything worked great locally, but now I would like to deploy the current release.

But the parse command line tool isn't working as expected (e.g. can't find modules) and I couldn't find a tutorial, how and what to deploy (especially to parse). I've used parse before as BaaS but not as a nodejs hosting service.

Where and how do I have to deploy following folders?

  • app.js
  • bin
  • main.js
  • node_modules
  • package.json
  • public
  • routes
  • views

Is parse able to download the node_modules if I just upload the package.json? And do I have to configure something on parse.com?

One error I always get if I want to deploy the app is following:

Update failed with Could not load triggers.
The error was Error: Module morgan.js not found
    at app.js:4:14
    at main.js:1:1

I use 'morgan' in my app.js:

var express = require('express');
var path = require('path');
//var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

And it is declared in the package.json:

{
  "name": "MyApp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "asyncawait": "0.7.4",
    "bluebird": "2.3.11",
    "express": "4.9.0",
    "body-parser": "1.8.1",
    "cookie-parser": "1.3.3",
    "morgan": "1.3.0",
    "serve-favicon": "2.1.3",
    "debug": "2.0.0",
    "jade": "1.6.0"
  }
like image 919
cansik Avatar asked Jan 10 '23 09:01

cansik


2 Answers

On Parse Could you can only use those few node modules that are already pre-installed, like expressjs with jade templating, some express middlewares and few other ones. There is no npm install step that would install dependencies from your package.json. That's why you've got the error about missing morgan module.

like image 59
lukaszfiszer Avatar answered Jan 16 '23 22:01

lukaszfiszer


It's worth noting that you can create and add your "own" modules, so I'm not sure it's 100% correct to say "you can only use those few node modules that are already pre-installed."

https://parse.com/tutorials/integrating-with-third-party-services

However, it is fair to say it isn't as simple as installing a node module with npm. You'll have to write your own integration.

like image 27
mbrauh Avatar answered Jan 16 '23 20:01

mbrauh