There are a lot of manuals for migrating Parse servers to different platforms but none of them say which kind of plugins and packages are needed for those web applications which work with Expressjs on the cloud. Does anybody have any suggestions for this problem?

I went through the steps below on an Amazon AWS server with an Ubuntu instance. Everything is OK for API but not for the web app Expressjs.

node install

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs git  
sudo apt-get update
sudo npm install -g parse-server pm2
sudo npm install -g express@3.1.0 underscore parse-express-https-redirect 
sudo npm install -g parse-express-raw-body ejs@1.0.0 parse-express-cookie-session

At the second step, I tried to run parse-server with pm2 service of node as below:

Create pm2 server with Nodejs

sudo useradd --create-home --system parse
sudo passwd parse

sudo su parse
cd ~
mkdir -p ~/cloud

cp -r /tmp/my-cloud-files             /home/parse/
                         \__ cloud
                              \__ main.js
                              \__ app.js
                              \__ ...
                         \__ public
                         \__ config

nano ecosystem.json

  "apps" : [{
    "name"        : "parse-wrapper",
    "script"      : "/usr/bin/parse-server",
    "watch"       : true,
    "merge_logs"  : true,
    "cwd"         : "/home/parse",
    "env": {
       "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
       "PARSE_SERVER_DATABASE_URI":    "mongodb://mongo_user:mongo_user_pass@localhost:27017/takimtakip",
       "PARSE_SERVER_APPLICATION_ID": "application_id",
       "PARSE_SERVER_MASTER_KEY": "application_master_key",

export NODE_PATH= (echo $NODE_PATH):.

pm2 start ecosystem.json
pm2 list

But when I looked at the pm2 log file, I see the following

pm2 show parse-wrapper

│ status            │ online                                         │
│ name              │ parse-wrapper                                  │
│ restarts          │ 72402                                          │
│ uptime            │ 0s                                             │
│ script path       │ /usr/bin/parse-server                          │
│ script args       │ N/A                                            │
│ error log path    │ /home/parse2/.pm2/logs/parse-wrapper-error.log │
│ out log path      │ /home/parse2/.pm2/logs/parse-wrapper-out.log   │
│ pid path          │ /home/parse2/.pm2/pids/parse-wrapper.pid       │
│ interpreter       │ node                                           │
│ interpreter args  │ N/A                                            │
│ script id         │ 0                                              │
│ exec cwd          │ /home/parse                                    │
│ exec mode         │ fork_mode                                      │
│ node.js version   │ 5.10.1                                         │
│ watch & reload    │ ✘                                              │
│ unstable restarts │ 0                                              │
│ created at        │ 2016-04-15T14:42:09.280Z                       │

tail -f /home/parse2/.pm2/logs/parse-wrapper-error.log

TypeError: Cannot read property 'defaults' of undefined
at module.exports (/home/parse2/node_modules/parse-express-cookie-session/index.js:64:26)
at Object.<anonymous> (/home/parse2/cloud/app.js:25:9)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function._load (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/parse2/cloud/main.js:1:63)

I would highly recommend you start from the parse-server-example project. It is an example of a node.js application that uses the parse-server. As far as I can tell it serves as the best documentation on how to create an application that uses parse-server.

From there you really only need to modify the index.js file for all configuration to use it as-is.

| improve this answer | |
  • To avoid link rot it may be helpful to copy relevant sections of the links into this answer. – shearn89 May 13 '16 at 8:33

Try this way! Code block was explained with comments.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
var fs = require('fs');

var api = new ParseServer({
    databaseURI: 'mongodb://user:pass@localhost:27017/parse', // Connection string for your MongoDB database
    appId: 'your app id',
    masterKey: 'your app master key', // Keep this key secret!
    serverURL: 'https://localhost:1337/parse' // Don't forget to change to https if needed

var options = {
    key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
    cert: fs.readFileSync('/etc/letsencrypt/live/example.com/fullchain.pem')

// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var httpsServer = require('https').createServer(options,app);

httpsServer.listen(1337, function() {
    console.log('parse-server-example running on port 1337.');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.