not support esm syntax
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- tooling
Research direction
Reproduce the failure while Egg loads config/plugin.ts, then trace the require path through @eggjs/utils/dist/commonjs/import.js and the callers in @eggjs/core/src/utils/index.ts and egg_loader.ts. Determine the expected ESM behavior from the report and verify that loading a TypeScript config under a package with "type": "module" no longer raises ERR_REQUIRE_ESM.
Written by the indexing model from the issue text.
Description
package.json
"dependencies": {
"@eggjs/tegg": "^3.5.2",
"@eggjs/tegg-aop-plugin": "^3.5.2",
"@eggjs/tegg-config": "^3.2.3",
"@eggjs/tegg-controller-plugin": "^3.5.2",
"@eggjs/tegg-eventbus-plugin": "^3.5.2",
"@eggjs/tegg-plugin": "^3.5.2",
"@eggjs/tegg-schedule-plugin": "^3.5.2",
"alova": "latest",
"axios": "^1.6.8",
"big.js": "latest",
"crypto-js": "^4.2.0",
"dayjs": "latest",
"egg": "^4.0.10",
"egg-redis": "^2.6.0",
"egg-scripts": "^2.17.0",
"egg-swagger-doc": "^2.3.2",
"egg-tracer": "^2.0.0",
"egg-validate": "^2.0.2",
"lodash": "^4.17.21",
"lodash-es": "4.17.21",
"prom-client": "^15.1.3",
"puppeteer": "^24.4.0",
"skywalking-backend-js": "^0.7.0",
"zmn-ratel-sdk-sign": "^1.0.2"
},
"devDependencies": {
"@eggjs/tsconfig": "1",
"@types/mocha": "10",
"@types/node": "20",
"@zmn/eslint-plugin": "latest",
"@zmn/prettier-config": "latest",
"@zmn/readmelint": "latest",
"@zmn/treelint": "latest",
"egg-bin": "6",
"egg-mock": "^5.15.1",
"husky": "latest",
"jest": "latest",
"lint-staged": "latest",
"typescript": "5"
},
error in terminal
2025-03-12 17:43:17,792 ERROR 39569 nodejs.Error: [@eggjs/core] load file: /Users/macbookpro/Documents/zmn/zmn-amis/packages/zmn-service/config/plugin.ts, error: Must use import to load ES Module: /Users/macbookpro/Documents/zmn/zmn-amis/packages/zmn-service/config/plugin.ts
require() of ES modules is not supported.
require() of /Users/macbookpro/Documents/zmn/zmn-amis/packages/zmn-service/config/plugin.ts from /Users/macbookpro/Documents/zmn/zmn-amis/node_modules/@eggjs/utils/dist/commonjs/import.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /Users/macbookpro/Documents/zmn/zmn-amis/packages/zmn-service/package.json.
require() of ES modules is not supported.
require() of /Users/macbookpro/Documents/zmn/zmn-amis/packages/zmn-service/config/plugin.ts from /Users/macbookpro/Documents/zmn/zmn-amis/node_modules/@eggjs/utils/dist/commonjs/import.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /Users/macbookpro/Documents/zmn/zmn-amis/packages/zmn-service/package.json.
at Object.loadFile (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/@eggjs/core/src/utils/index.ts:92:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AgentWorkerLoader.readPluginConfigs (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/@eggjs/core/src/loader/egg_loader.ts:547:22)
at async AgentWorkerLoader.loadAppPlugins (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/@eggjs/core/src/loader/egg_loader.ts:468:24)
at async AgentWorkerLoader.loadPlugin (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/@eggjs/core/src/loader/egg_loader.ts:415:23)
at async AgentWorkerLoader.loadConfig (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/egg/src/lib/loader/AgentWorkerLoader.ts:12:5)
at async Agent.loadConfig (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/egg/src/lib/egg.ts:191:5)
at async Agent.load (/Users/macbookpro/Documents/zmn/zmn-amis/node_modules/egg/src/lib/egg.ts:195:5)
at async /Users/macbookpro/Documents/zmn/zmn-amis/node_modules/egg/src/lib/egg.ts:179:7
cause: {"code":"ERR_REQUIRE_ESM"}
cause:
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·