Javascript 节点JS:意外令牌非法

Javascript 节点JS:意外令牌非法,javascript,node.js,keystonejs,Javascript,Node.js,Keystonejs,我正在尝试启动服务器, 但是我得到了这个错误 /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

我正在尝试启动服务器, 但是我得到了这个错误

/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

您尝试使用的语法是新ES2015标准的一部分。确保您使用的节点版本支持


我建议至少使用node 4.2.3,因为它是LTS版本,没有iojs,因为它合并回node。

您尝试使用的语法是新ES2015标准的一部分。确保您使用的节点版本支持


我建议至少使用node 4.2.3,因为它是LTS版本,而不使用iojs,因为它已合并回node。

您正在运行哪个版本的node?您可能不支持模板字符串。当我运行$nodejs--version时,我得到v4.2.3,但当我运行$node--version时,我得到v0.12.7,即,谢谢@ndugger您是使用
node
还是
nodejs
运行服务器?我使用node@ben运行服务器,然后使用
nodejs
运行服务器……您运行的是哪个版本的node?您可能不支持模板字符串。当我运行$nodejs--version时,我得到v4.2.3,但当我运行$node--version时,我得到v0.12.7,即,谢谢@nduggerWell您是用
节点运行服务器还是用
节点运行服务器
?我用节点@ben运行服务器,然后用
节点运行服务器
…但是当我运行$nodejs时--版本我看到了v.4.2.3,但当我运行$nodejs时--版本我看到了v.4.2.3
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();
};