尝试实现遵循official handbook的模块时,我收到以下错误消息:
未捕获ReferenceError:未定义导出
在app.js:2
但是在我的代码中,我从来没有使用过exports这个名字。
我该如何解决这个问题呢?
文件
app.ts
let a = 2;
let b:number = 3;
import Person = require ('./mods/module-1');module-1.t
export class Person {
constructor(){
console.log('Person Class');
}
}
export default Person;tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"outDir": "scripts/"
},
"exclude": [
"node_modules"
]
}发布于 2021-03-15 18:39:59
我在SSR客户端部分使用了这样的错误,因为它使用了一个用tsconfig.json compilerOptions构建的库作为target: ES5,它带来了使用CommonJS进行模块解析的tsc CLI Options Compiler Options:target === "ES3" or "ES5" ? "CommonJS" : "ES6"。当它使用目标ESNext时。
https://stackoverflow.com/questions/43042889
复制相似问题