我正在将我的代码从一台服务器转移到一台新服务器而且我一直收到同样的错误。我不确定为什么这些服务器是相同的并且应该几乎相同,代码在服务器A上工作但在服务器B上我得到了这个错误。
./ router 为空,从不需要
错误
TypeError: configure is not a function
at Object.<anonymous> (/var/www/html/mm3/controller.js:15:1)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
我的节点服务器文件
"use strict";
var fs = require('fs');
var mkdirp = require('mkdirp');
var archiver = require('archiver');
var server = require('http').Server(app); // not sure what this is ?
var configure = require('./router');
var express = require('express');
var request = require('request');
var nodePardot = require('node-pardot');
var bodyParser = require('body-parser');
var rp = require('request-promise');
var app = express();
var port = process.env.PORT || 3331;
var router = express.Router();
configure(router);
var password = 'd.0s../d9';
var userkey = 'hgsydghdupi';
var emailAdmin = 'fs@fee.co.uk';
app.use(bodyParser.urlencoded({limit: '100mb',extended: true}));
app.use(bodyParser.json({limit: '100mb'}));
app.use(express.static('/public'));
app.use(express.static('/js'));
app.use(express.static('/tmp'));
app.use(express.static('/img'));
app.use(express.static('/css'));
app.get('/mm3', function(req, res){
res.sendfile(__dirname +'/index.html')
});
app.listen(port);
console.log('Test server started! At http://localhost:' + port); // Confirms server start
app.post('/mm3/savePhotos', function (req, res) {
var folder = Math.random().toString(36).substr(2, 20);
var photos = req.body;
var counts = 0;
var callback = function(counts){
if(counts < photos.length){
saveBase64(photos[counts],folder,counts,callback);
}else{
var response = {"folder":folder, "photos": photos.length};
res.send(response)
}
};
saveBase64(photos[counts],folder,counts,callback);
});
app.post('/mm3/downloadZip', function(req, res){
var photos = req.body;
var out = photos[0];
var test = out.split('/');
var loc = test.pop();
var end = test.join('/');
var outName = '/var/www/html' + end +'/MockUp.zip';
var output = fs.createWriteStream(outName);
var archive = archiver('zip', {store: true });
var zip = function(photos, f){
for(var t = 0; t < photos.length; t++){
var file = 'mockUp'+ t +'.jpg';
var from = '/var/www/html' + photos[t];
archive.file( from, { name: file });
}
f();
};
output.on('close', function() {
var photos = req.body;
var out = photos[0];
var test = out.split('/');
var loc = test.pop();
var end = test.join('/');
res.send(end + '/MockUp.zip');
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
zip(photos, f);
function f(){
archive.finalize();
}
});