【发布时间】:2019-05-27 11:30:24
【问题描述】:
我正在尝试在 node.js 中导出此类:
export class className {
static method1(param1) {
// do something
}
static method2(param1, param2) {
// do something
}
}
但它让我在终端出现以下错误:
complete_path.....\node_modules@babel\runtime\helpers\esm\classCallCheck.js:1 [2] (function (exports, require, module, __filename, __dirname) { 导出默认函数 _classCallCheck(instance, Constructor) { [2]
^^^^^^ [2] [2] SyntaxError: Unexpected token export [2] at new 脚本 (vm.js:83:7) [2] at createScript (vm.js:267:10) [2] at Object.runInThisContext (vm.js:319:10) [2] 在 Module._compile (内部/模块/cjs/loader.js:685:28) [2] 在 Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10) [2] 在 Module.load (internal/modules/cjs/loader.js:620:32) [2]
在 tryModuleLoad (internal/modules/cjs/loader.js:560:12) [2] 在 Function.Module._load (internal/modules/cjs/loader.js:552:3) [2]
在 Module.require (internal/modules/cjs/loader.js:658:17) [2] 在 需要(内部/模块/cjs/helpers.js:22:18)[2] [nodemon] 应用程序 崩溃 - 在开始之前等待文件更改...
【问题讨论】: