Skip to content

not support esm syntax #296

@ranwawa

Description

@ranwawa

config/plugin.ts

import { EggPlugin } from 'egg';
const plugin: EggPlugin = {}
export default plugin

package.json

{
  "type": "module"
}

errors in terminal

2025-03-11 19:19:16,497 ERROR 97119 nodejs.ERR_REQUIRE_ESMError: [egg-core] load file: /Users/macbookpro/Documents/zmn/zmn-rww-mcp/config/plugin.ts, error: Must use import to load ES Module: /Users/macbookpro/Documents/zmn/zmn-rww-mcp/config/plugin.ts
require() of ES modules is not supported.
require() of /Users/macbookpro/Documents/zmn/zmn-rww-mcp/config/plugin.ts from /Users/macbookpro/Documents/zmn/zmn-rww-mcp/node_modules/egg-core/lib/utils/index.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-rww-mcp/package.json.

require() of ES modules is not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions