nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.65k stars 2.36k forks source link

[Mac]: Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. #28395

Open YonatanKra opened 1 month ago

YonatanKra commented 1 month ago

Current Behavior

I'm getting an error for every Nx command. Even a simple nx run myApp:test fails.

Running with Verbose gives me the following error:

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
      An error occurred while processing files for the @nx/eslint/plugin plugin.
    - apps/myProject/eslint.config.js: Config (unnamed): Key "plugins": Cannot redefine plugin "@typescript-eslint".
      ConfigError: Config (unnamed): Key "plugins": Cannot redefine plugin "@typescript-eslint".
          at rethrowConfigError (/Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/@eslint+config-array@0.17.1/node_modules/@eslint/config-array/dist/cjs/index.cjs:303:8)
          at /Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/@eslint+config-array@0.17.1/node_modules/@eslint/config-array/dist/cjs/index.cjs:1098:5
          at Array.reduce (<anonymous>)
          at FlatConfigArray.getConfigWithStatus (/Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/@eslint+config-array@0.17.1/node_modules/@eslint/config-array/dist/cjs/index.cjs:1091:43)
          at FlatConfigArray.getConfig (/Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/@eslint+config-array@0.17.1/node_modules/@eslint/config-array/dist/cjs/index.cjs:1120:15)
          at ESLint.calculateConfigForFile (/Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/eslint@9.8.0/node_modules/eslint/lib/eslint/eslint.js:1187:24)
          at async ESLint.isPathIgnored (/Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/eslint@9.8.0/node_modules/eslint/lib/eslint/eslint.js:1209:24)
          at async /Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/@nx+eslint@19.8.0_@swc-node+register@1.9.1_@swc+core@1.5.7_@types+node@18.16.9_eslint@9.8.0_nx@19.8.0/node_modules/@nx/eslint/src/plugins/plugin.js:123:19
          at async Promise.all (index 0)
          at async internalCreateNodesV2 (/Users/mainUser/Projects/personal-projects/myProject/node_modules/.pnpm/@nx+eslint@19.8.0_@swc-node+register@1.9.1_@swc+core@1.5.7_@types+node@18.16.9_eslint@9.8.0_nx@19.8.0/node_modules/@nx/eslint/src/plugins/plugin.js:106:5)

Expected Behavior

I expect it to run the tests

GitHub Repo

No response

Steps to Reproduce

  1. Installed a new nuxt project with multiple apps setup
  2. Added a new API file
  3. Added a new test file for the API file
  4. Tried to run the test
  5. Got the error

Nx Report

Node : 20.3.0 OS : darwin-x64 Native Target : x86_64-macos pnpm : 8.6.12

nx (global) : 20.0.0 nx : 20.0.0 @nx/js : 20.0.0 @nx/jest : 20.0.0 @nx/eslint : 20.0.0 @nx/workspace : 20.0.0 @nx/devkit : 20.0.0 @nx/esbuild : 20.0.0 @nx/eslint-plugin : 20.0.0 @nx/node : 20.0.0 @nx/nuxt : 20.0.0 @nx/playwright : 20.0.0 @nx/vite : 20.0.0 @nx/web : 20.0.0 typescript : 5.5.2

Registered Plugins: @nx/eslint/plugin @nx/jest/plugin @nx/vite/plugin @nx/nuxt/plugin @nx/playwright/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

drwpow commented 4 weeks ago

What does your ESLint config look like? Do you have the @typescript-eslint plugin declared more than once like the error shows?

dpickett commented 2 weeks ago

I experience this issue as well because I have another dependency that references the typescript-eslint plugin. This looks like an issue with the new flat configuration style as noted here: https://github.com/eslint/eslintrc/issues/135

I'm not sure there's much NX can do until there's some kind of registry paradigm for eslint plugins.

YonatanKra commented 2 weeks ago

It's a brand new Nx project. Changed nothing. My config looks like this:

const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
const baseConfig = require('../../eslint.config.js');

const compat = new FlatCompat({
  baseDirectory: __dirname,
  recommendedConfig: js.configs.recommended,
});

module.exports = [
  ...baseConfig,
  {
    files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
    // Override or add rules here
    rules: {},
  },
  ...compat.extends('@nuxt/eslint-config'),
  {
    files: ['**/*.vue'],
    languageOptions: {
      parserOptions: { parser: require('@typescript-eslint/parser') },
    },
  },
  { ignores: ['.nuxt/**', '.output/**', 'node_modules'] },
];

Even if I delete


    languageOptions: {
      parserOptions: { parser: require('@typescript-eslint/parser') },
    },

Which is the only mention of eslint in the project, I get the error because it stems from @nx/eslint/plugin which I have no control over.

Any way to bypass this without turning off linting?

YonatanKra commented 1 week ago

@jaysoo @drwpow This happens for me with a fresh nuxt app install. I did nothing - just installed a new Nx project and ran pnpm start. Is there any workaround?