应用程序.js
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
module.exports = app;
我尝试过使用不同的摩根标识符,而不仅仅是“dev”,比如“common”。但是,express 应用程序内部的 JavaScript 错误不会被报告给控制台,并且路由只会返回一个错误代码,例如 400 左右。
错误.js
module.exports.removeDuplicates = function(x) {
y = [];
for(var i=0; i<x.length; i++) {
if(!y.includes(x[i]))
y.push(x[i]);
}
thisisanerror
return y;
}