小编ash*_*ash的帖子

nodejs/express有时候不起作用

我在centos服务器上运行nodejs和express.我做了下面的代码,当我做它时工作得很好......现在它的给出错误(我甚至没有触摸它).

奇怪的是,如果我删除所有的行并逐一添加它再次起作用; 但我不明白为什么它会停止工作?

我的代码:

App.js文件:

var express = require('express'),
mongo = require('mongodb').MongoClient,
http = require('http'),
path = require('path'),
bodyParser = require('body-parser'),
passport = require('passport-local'),
config = require('./config/config.json');
//CONNECT TO DATABASE - i removed the pass & username when posting
mongo.connect("mongodb://{username}:{pass}@ds037617.mongolab.com:37617/{db}", function (err, db) {
        if (err) {
        throw err;
        } else {
            console.log("successfully connected to the database");
        }
        db.close();
    });
    var publicUser = require('./routes/publicUser'),
    storeUser = require('./routes/publicUser'),
    adminUser = require('./routes/publicUser');
    app = express();
    app.set('views', path.join(__dirname, 'views'));
    app.set('view engine', 'jade');
    app.use('/', …
Run Code Online (Sandbox Code Playgroud)

node.js express

-3
推荐指数
1
解决办法
1098
查看次数

标签 统计

express ×1

node.js ×1