相关疑难解决方法(0)

ReferenceError:导出未在 ES 模块范围中定义

我是打字稿的新手,当我编译代码时,它编译正确,但是当我使用节点运行程序时,我收到此错误 ReferenceError: Exports is not Defined in ES modulescope


ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and 'D:\projects\pro8\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///D:/projects/pro8/await.js:40:1
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)
Run Code Online (Sandbox Code Playgroud)

打字稿代码

import fetch from …
Run Code Online (Sandbox Code Playgroud)

javascript node.js async-await typescript

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

async-await ×1

javascript ×1

node.js ×1

typescript ×1