nrwl/nx

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

manuphatak opened this issue · 1 comments

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

For troubleshooting purposes:

  • I've tried nx reset -- it does not fix. I left it out because it's not required to recreate this.
  • I've tried using npm instead of pnpm
  • I've tried npx nx serve <app-name> (as recommended by the readme)
    manuphataknx-jest-bug -- 2024-05-10 at 11 45 13@2x
  • I've tried adding verbatimModuleSyntax: false to the root /tsconfig.base.json file