Uncaught ReferenceError: exports is not defined in filed generated by Typescript

前端 未结 7 2129
暗喜
暗喜 2021-02-01 02:41

I\'m trying to get started with Typescript for Electron development. After wrestling with getting typing for node and jquery, I finally got my .ts file error free.

The p

7条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 02:58

    I've fixed mine with the following:

    tsconfig.json

    {
        "compilerOptions": {
            "target": "ESNext",
            "module": "CommonJS",
            "lib": [
                "DOM",
                "ES5"
            ],
            "esModuleInterop": true
        }
    }
    

    Adding the esModuleInterop

    Removing the "type": "module" from the package.json

提交回复
热议问题