NodeJS application startup problem in UOL Hosting

1

Galera,

I'm running my application running 100% on my local machine, but when I upload the files to my Node hosting on UOL HOST it does not work on startup. I'm using the same version of the UOL node (4.4.5).

The error you have in nodejs.log is:

module.js:341
    throw err;
    ^

Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/opt/web/webapps/server.js:14:16)
    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.Module.runMain (module.js:447:10)
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::8080
    at Object.exports._errnoException (util.js:893:11)
    at exports._exceptionWithHostPort (util.js:916:20)
    at Server.__dirname.Server.Server._listen2 (net.js:1246:14)
    at listen (net.js:1282:10)
    at Server.__dirname.Server.Server.listen (net.js:1378:5)
    at Object.<anonymous> (/opt/web/webapps/server.js:76:8)
    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.Module.runMain (module.js:447:10)
    at startup (node.js:148:18)
    at node.js:405:3
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
events.js:154
      throw er; // Unhandled 'error' event
      ^

My package.json looks like this:

{
  "name": "pokestop",
  "version": "0.0.1",
  "description": "",
  "main": "server.js",
  "author": "",
  "dependencies": {
    "body-parser": "~1.0.2",
    "colors": "^0.6.2",
    "express": "~4.7.2",
    "mongoose": "~3.8.14",
    "slug": "^0.9.1",
    "morgan": "~1.1.1"
  },
  "devDependencies": {
    "gulp": "~3.6.2",
    "gulp-concat": "~2.2.0",
    "gulp-filter": "~0.4.1",
    "gulp-minify-css": "~0.3.7",
    "gulp-minify-html": "~0.1.4",
    "gulp-rename": "~1.2.0",
    "gulp-uglify": "~0.3.1",
    "nodemon": "^1.10.0"
  }
}

And my server.js looks like this:

'use strict';

var express  = require('express');
var database = require('./server/config/database');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var http = require('http');
var colours = require('colors');
var logger   = require('morgan');
var allowCors = function(req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  //res.header('Access-Control-Allow-Credentials', 'true');

    next();
};

require('colors');

var routes = require('./server/routes.js');
var app = express();
var mongoOptions = { db: { safe: true }};
mongoOptions.user = database.user;
mongoOptions.pass = database.pass;

console.log('Running mongoose version %s', mongoose.version);

mongoose.connect(database.url, mongoOptions, function (err, res) {
  if (err) { 
    console.log ('ERROR connecting to: ' + database.url + '. ' + err);
  } else {
    console.log ('Successfully connected to: ' + database.url);
  }
});

app.set('port', process.env.PORT || 8080);

app.use(express.static(__dirname + '/public')); 

app.use(logger('dev'));

app.use(bodyParser.json());

app.use(allowCors);

routes(app);

var server = http.createServer(app);

server.listen(app.get('port'), function() {
    console.log('Express HTTP server listening on port ' .
        red + app.get('port'));
});

var db = mongoose.connection;
db.on('error', console.error);

process.on('SIGINT', function() {
  db.close(function () {
    console.log('Mongoose default connection disconnected through app termination');
    process.exit(0);
  });
});

Does anyone help me? I'm here for hours and I do not solve the problem. I have already called them, but they will only respond there for Monday and I would like to put my application to run before.

    
asked by anonymous 14.08.2016 / 07:51

0 answers