gpt4 book ai didi

javascript - Node JS : Unexpected token ILLEGAL

转载 作者:太空宇宙 更新时间:2023-11-04 02:57:33 26 4
gpt4 key购买 nike

正在尝试启动服务器,但我收到此错误

/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 的 Node 版本

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

关于javascript - Node JS : Unexpected token ILLEGAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417754/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com