Skip to content

The "@nx/jest/plugin" plugin threw an error ... ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled. #23310

Open
@manuphatak

Description

Current Behavior

 NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
  The "@nx/jest/plugin" plugin threw an error while creating nodes from apps/nx-jest-bug/jest.config.ts:
    Error: Jest: Failed to parse the TypeScript config file /Users/manu/Code/manuphatak/nx-jest-bug/apps/nx-jest-bug/jest.config.ts
      TSError: ⨯ Unable to compile TypeScript:
    apps/nx-jest-bug/jest.config.ts(2,1): error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled.
    
        at readConfigFileAndSetRootDir (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/jest-config@29.7.0_@types+node@18.16.20_ts-node@10.9.1/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:116:13)
        at async readInitialOptions (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/jest-config@29.7.0_@types+node@18.16.20_ts-node@10.9.1/node_modules/jest-config/build/index.js:403:13)
        at async readConfig (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/jest-config@29.7.0_@types+node@18.16.20_ts-node@10.9.1/node_modules/jest-config/build/index.js:147:48)
        at async buildJestTargets (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/@nx+jest@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@types+node@18.16.20_nx@19.0.2_ts-_ct5ujyi7caxlebalyox5otyjgu/node_modules/@nx/jest/src/plugins/plugin.js:76:20)
        at async Array.exports.createNodes (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/@nx+jest@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@types+node@18.16.20_nx@19.0.2_ts-_ct5ujyi7caxlebalyox5otyjgu/node_modules/@nx/jest/src/plugins/plugin.js:58:14)
        at async /Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/plugins/utils.js:49:27
        at async Promise.all (index 0)
        at async runCreateNodesInParallel (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/plugins/utils.js:66:5)
        at async Promise.all (index 3)
        at async processFilesAndCreateAndSerializeProjectGraph (/Users/manu/Code/manuphatak/nx-jest-bug/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js:148:43)

https://app.warp.dev/block/gSjFdAYBGV7r6GuDLtEu1a

Expected Behavior

The server runs

GitHub Repo

https://github.com/manuphatak/nx-jest-bug

Steps to Reproduce

  1. run npx create-nx-workspace@latest --pm pnpm
  2. choose a node -> nest app (also happens with express) in an integrated monorepo
    manuphataknx-jest-bug -- 2024-05-10 at 11 33 55@2x
  3. run cd <app-name>
  4. run nx serve <app-name>

Nx Report

nx report --verbose

 NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.

Pass --verbose to see the stacktraces.

manuphataknx-jest-bug -- 2024-05-10 at 11 37 02@2x

Failure Logs

No response

Package Manager Version

node@v20.13.1, pnpm@8.15.6

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

scope: testing toolsIssues related to Cypress / Jest / Playwright / Vitest support in Nxstaletype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions