egg 使用ts时tsconfig.json文件配置module只能使用CommonJS,使用ES会报错

cczfrluj  于 2个月前  发布在  其他
关注(0)|答案(1)|浏览(33)

Your detail info about the Bug:

{
  "extends": "@eggjs/tsconfig",
  "compilerOptions": {
    "declaration": false,
    "paths": {
      "@/module/*": ["app/module/*"]
    },
    "baseUrl": ".",
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "module": "ES6",
    // "moduleResolution": "Node",
    // "target": "ES6",
    // "esModuleInterop": true
  }
}

我使用的第三方包node-fetch3只支持es模块化,所以无法使用。

Reproduction Repo

None

Node Version

18.16.1

Eggjs Version

3.15.0

Plugin Name and its version

"egg-mysql": "^4.0.0",     "egg-scripts": "^2.17.0",     "egg-tracer": "^2.0.0",

Platform and its version

win11

46scxncf

46scxncf1#

对,目前 egg 只支持 commonjs。esm 还在进行中,估计是一个很长期的过程才能全链路支持。

相关问题