我将我的应用程序从较旧的库更新到最新的库但我遇到了不一致的错误 我的文章:
npm list --depth=0
├── consolidate@0.10.0
├── express@4.4.4
├── hogan.js@3.0.2
├── node-uuid@1.4.1
└── socket.io@1.0.6
以下是我运行的代码示例。完整代码here。
var express = require('express');
var http = require('http');
var uuid = require('node-uuid');
var consolidate = require('consolidate');
//////////////////////
// Server setup
//////////////////////
var app = express();
app.engine('html', consolidate.hogan);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.enable('view cache');
app.disable('view layout');
var server = http.createServer(app);
var io = require('socket.io').listen(server);
io.set('log level', 1); // reduce logging
server.listen(9000);
//////////////////////
// Routing
//////////////////////
// Partials used in many rendering views
function hoganPartials() {
return {
head : 'common/head',
mainHeader : 'common/mainHeader',
mainFooter : 'common/mainFooter'
};
};
app.use('/files', express.static(__dirname + '/files'));
app.get('/about', function(req, res) {
res.render('about', {
partials: hoganPartials(),
title : 'Title - About'
});
});
因此,当我运行此代码时,我有时会一个随机错误:
错误1
SyntaxError: Unexpected token ( at Object.Function (<anonymous>)
at Object.Hogan.makePartials (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:301:28)
at Object.Hogan.makeTemplate (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:290:25)
at Object.Hogan.generate (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:280:17)
at Object.Hogan.compile (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:416:21)
at Function.exports.hogan.render (/home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:448:56)
at /home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:144:25
at /home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:97:5
at fs.js:271:14
at Object.oncomplete (fs.js:107:15)
错误2
SyntaxError: Unexpected token ( at Object.Function (<anonymous>)
at Object.Hogan.makePartials (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:301:28)
at Object.Hogan.makeTemplate (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:290:25)
at Object.Hogan.generate (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:280:17)
at Object.Hogan.compile (/home/philaeux/dota2draft/node_modules/hogan.js/lib/compiler.js:416:21)
at Function.exports.hogan.render (/home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:448:56)
at /home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:144:25
at read (/home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:91:22)
at /home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:142:9
at next (/home/philaeux/dota2draft/node_modules/consolidate/lib/consolidate.js:117:38)
我试图降级一些libs但没有成功。我无法记住我从哪个版本开始(可能表达&lt; 4.0.0)。我完全迷失在这一个...... 谢谢你的时间。