我正在尝试启动服务器,
但我得到这个错误
/home/ceddy/syd/sydjs/node_modules/keystone/admin/server/middleware/logError.js:7
var msg = `[${endpoint}]`;
^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/ceddy/syd/sydjs/node_modules/babel-register/lib/node.js:138:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.createDynamicRouter (/home/ceddy/syd/sydjs/node_modules/keystone/admin/server/app/createDynamicRouter.js:65:21)
at createApp (/home/ceddy/syd/sydjs/node_modules/keystone/server/createApp.js:63:72)
at [object Object].initExpressApp (/home/ceddy/syd/sydjs/node_modules/keystone/lib/core/initExpressApp.js:5:46)
at [object Object].start (/home/ceddy/syd/sydjs/node_modules/keystone/lib/core/start.js:47:7)
at Object.<anonymous> (/home/ceddy/syd/sydjs/keystone.js:94:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
当我查看似乎在第7行引起错误的文件时,我没有看到任何错误,如控制台所示...
我在这里错过了什么吗,是什么原因?
提前致谢
module.exports = function (req, res, next) {
res.logError = function logError(endpoint, description, err) {
if (arguments.length === 2 && typeof description !== 'string') {
err = description;
description = null;
}
var msg = `[${endpoint}]`;
msg += description ? (` ${description}:`) : ' error:';
if (err) {
console.log(msg, err.message, '\n' + err.stack);
} else {
console.log(msg);
}
};
next();
};
最佳答案
您尝试使用的语法是新ES2015标准的一部分。确保使用支持Template Strings的节点版本
我建议至少使用节点4.2.3,因为它是LTS版本,而没有iojs,因为它已合并回节点。
关于javascript - Node JS:意外 token ILLEGAL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34417754/