Skip to content

"Cannot require() ES Module" when using Node 22 and @trivago/prettier-plugin-sort-imports #411

@cdeutsch

Description

@cdeutsch

What version of prettier-plugin-tailwindcss are you using?

For example: v0.7.1

What version of Tailwind CSS are you using?

For example: v3.4.10

What version of Node.js are you using?

For example: v22.20.0

What package manager are you using?

For example: npm@10.9.2

What operating system are you using?

For example: macOS

Describe your issue

  • Prettier version: 3.5.1
  • node version: 22.20.0
  • package manager: npm@10.9.2
  • IDE: Cursor 2.0.60

When loading Cursor, the ESLint Output window is showing ESLint crashing with the error:

2025-11-05 10:15:43.560 [error] An unexpected error occurred:
2025-11-05 10:15:43.560 [error] Error [ERR_INTERNAL_ASSERTION]: Unexpected module status 0. Cannot require() ES Module /node_modules/prettier/plugins/babel.mjs because it is not yet fully loaded. This may be caused by a race condition if the module is simultaneously dynamically import()-ed via Promise.all(). Try await-ing the import() sequentially in a loop instead. (from /node_modules/@trivago/prettier-plugin-sort-imports/lib/src/index.js)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at assert.fail (node:internal/assert:17:9)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:412:16)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1544:24)
    at Module._compile (node:internal/modules/cjs/loader:1695:5)
    at Module._extensions..js (node:internal/modules/cjs/loader:1848:10)
    at Module.load (node:internal/modules/cjs/loader:1448:32)
    at Module._load (node:internal/modules/cjs/loader:1270:12)
    at c._load (node:electron/js2c/node_init:2:17993)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)

To Reproduce

Only seems to happen when using both @trivago/prettier-plugin-sort-imports and prettier-plugin-tailwindcss

**Configuration File **

.prettierrc

{
  "arrowParens": "always",
  "printWidth": 120,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "importOrder": [
    "^@(A/|C/)(.*)$",
    "^@/(.*)$",
    "^src/(.*)$",
    "^[./].*(?<!\\.(c|le|sc)ss)$",
    "^[^./].*\\.(c|le|sc)ss$",
    "^[./].*\\.(c|le|sc)ss$"
  ],
  "importOrderSeparation": true,
  "importOrderSortSpecifiers": true,
  "plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss"]
}

Related:

Not sure whose issue this is so it's mentioned at @trivago/prettier-plugin-sort-imports as well.

trivago/prettier-plugin-sort-imports#380 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions