0
當我嘗試導入外部模塊並嘗試編譯我的代碼時,出現此錯誤消息:app.ts:1 Uncaught ReferenceError: require is not defined at app.ts:1
。打字稿版本是:2.1.6。導入/導出模塊 - Typescript
我app.ts文件:
import {PI, calcCircumference } from "./math/circle";
console.log(PI);
console.log(calcCircumference(10));
//console.log();
我circle.ts文件
export const PI: number = 3.14;
export function calcCircumference(diameter: number) {
return diameter * PI;
};
我tsconfig.json文件
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true
}
}
Thanks all