【发布时间】:2019-10-18 14:10:36
【问题描述】:
我遇到了一个以前从未遇到过的问题。 我正在开发一个由 Microsoft Bot Framework 提供支持的聊天机器人,因此我已经在几周前将我的项目上传到 azure,一切正常。
今天我上传了我的项目的新更新,这个版本在我的电脑上完美运行。但是当我上传到 Azure 时,日志会抛出这个错误
SyntaxError: Unexpected token =
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
Wed Oct 16 2019 08:25:08 GMT+0000 (Greenwich Mean Time): Application has thrown an uncaught exception and is terminated:
此错误由“userCourses = {}”第 2 行引发:
class UserProfil {
userCourses = {}
constructor(login, firstname, lastname, lastaccess) {
this.login = login;
this.firstname = firstname;
this.lastname = lastname;
this.lastaccess = lastaccess;
}
}
module.exports.UserProfil = UserProfil
但它似乎对每个字符都抛出错误,例如“=({”所以这不是特别的行......这个项目完全可以在我的电脑上运行,并且一天前在 AZure 上运行过,所以我真的不知道是什么造成了这个大问题
有人遇到过这种情况吗?
谢谢! :-)
编辑:搜索后,我发现我的计算机运行 Nodejs 版本 12,并且此声明是 Nodejs 12 中的新声明,Azure 可能运行最后一个 LTS 版本(10),这就是它无法运行的原因。我已经在我的电脑上安装了 LTS 版本,抛出的错误和 Azure 一样:-)
【问题讨论】:
-
另外,使用
module.exports = {UserProfil}
标签: javascript node.js azure