Skip to content

[error] Cannot read properties of undefined (reading 'async') #17139

@ghost

Description

Environments:

  • Prettier Version: 3.5.1
  • Running Prettier via: CLI
  • Runtime: Node.js 22
  • Operating System: Debian Linux (WSL2)
  • Prettier plugins (if any): prettier-plugin-jsdoc, @trivago/prettier-plugin-sort-imports

Steps to reproduce:

I have been unable to create a minimal reproduction. Is there any way to get a more meaningful error message?

Expected behavior:

No error.

Actual behavior:

> prettier --write --cache .

[error] Cannot read properties of undefined (reading 'async')
 ELIFECYCLE  Command failed with exit code 1.

As described here, pnpm format (prettier --write .) creates the above error.

pnpm exec prettier --write . will work, and, like @adamalston described, running pnpm format right after that will work as well.

But the next call to pnpm format will error again.

NeoVIM reports the following on formatting an empty TypeScript module:

Failed to run formatter prettier.
[error] /home/user/company/ui/components/lib/Accordion.tsx: TypeError: Cannot read properties of undefined (reading 'async')
[error]     at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:306:22)
[error]     at Object.loadESMFromCJS [as .mjs] (node:internal/modules/cjs/loader:1411:24)
[error]     at Module.load (node:internal/modules/cjs/loader:1313:32)
[error]     at Function._load (node:internal/modules/cjs/loader:1123:12)
[error]     at TracingChannel.traceSync (node:diagnostics_channel:322:14)
[error]     at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
[error]     at Module.require (node:internal/modules/cjs/loader:1335:12)
[error]     at require (node:internal/modules/helpers:136:16)
[error]     at Object.<anonymous> (/home/user/company/ui/node_modules/.pnpm/@trivago+prettier-plugin-sort-imports@5.2.2_prettier@3.5.1/node_modules/@trivago/prettier-plugin-sort-imports/lib/src/index.js:14:15)
[error]     at Module._compile (node:internal/modules/cjs/loader:1562:14)

Metadata

Metadata

Assignees

Labels

locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions