Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new nx create missing @eslint/eslintrc dependency #29845

Closed
1 of 4 tasks
ktwbc opened this issue Feb 2, 2025 · 3 comments · Fixed by #29933
Closed
1 of 4 tasks

new nx create missing @eslint/eslintrc dependency #29845

ktwbc opened this issue Feb 2, 2025 · 3 comments · Fixed by #29933
Assignees
Labels
scope: linter Issues related to Eslint support in Nx type: bug

Comments

@ktwbc
Copy link

ktwbc commented Feb 2, 2025

Current Behavior

Created a brand new nx project, then imported into pnpm, then attempted build. Got error @eslint/eslintrc was missing which is true, it was not in package.json

Expected Behavior

A brand new project should compile

GitHub Repo

No response

Steps to Reproduce

  1. npx create-nx-workspace@latest (I did this through the Webstorm wizard for nx using the official nx plugin)
  2. using node 20
  3. for wizard:
  4. Create React app with framework of choice
  5. chose nextjs
  6. integrated monorepo
  7. picked my app name
  8. No on app router
  9. Yes on src
  10. none on e2e framework
  11. sass
  12. github actions
  13. At this point it installs with npm, creating my workspace
  14. brought up nX console in Webstorm
  15. click Refresh Workspace
  16. Projects -> build
  17. get immediate failure (Error: Cannot find module '../src/utils/find-workspace-root' shouldn't this also work??)
  18. go to terminal on MacOS
  19. cd into project folder
  20. run command in terminal: pnpm import
  21. Delete node_modules from folder with Finder
  22. run command in terminal: pnpm install
  23. run command: pnpm approve-builds
  24. select all scripts and allow them to run (swc/core, sharp, nx)
  25. go back to webstorm and nx console
  26. Projects -> build
  27. this will actually successfully build at this point
  28. Projects-> start
  29. this will run, can go to localhost 3000 at this point
  30. from terminal, run: nx reset
  31. Projects -> build now this will fail, Cannot find package '@eslint/eslintrc' imported from (path)/eslint.config.mjs
  32. From terminal, pnpm add @eslint/eslintrc -D
  33. Projects -> build this now works
  34. nx reset
  35. now we get a different error, Module @nx/react/plugins/jest in the transform option was not found.
    at this point I gave up. not sure why nx reset and then nx build throws various errors

Nx Report

⚠️ Unable to construct project graph.
Failed to process project graph.
     - apps/(projectname)/eslint.config.mjs: Error: Failed to load plugin '@next/next' declared in ' » eslint-config-next': Cannot find module '@next/eslint-plugin-next'
  Require stack:
  - /Volumes/dev/(projectname)/apps/(projectname)/__placeholder__.js
  Referenced from: /Volumes/dev/(projectname)/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/eslint-config-next/index.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
      at mod._resolveFilename (/Volumes/dev/(projectname)/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/eslint-config-next/index.js:50:26)
      at Function.resolve (node:internal/modules/helpers:187:19)
      at Module.resolve (file:///Volumes/dev/(projectname)/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js:23:46)
      at ConfigArrayFactory._loadPlugin (file:///Volumes/dev/(projectname)/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/lib/config-array-factory.js:1068:33)
      at ConfigArrayFactory._loadExtendedPluginConfig (file:///Volumes/dev/(projectname)/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/lib/config-array-factory.js:887:29)
      at ConfigArrayFactory._loadExtends (file:///Volumes/dev/(projectname)/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/lib/config-array-factory.js:808:29)
      at ConfigArrayFactory._normalizeObjectConfigDataBody (file:///Volumes/dev/(projectname)/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/lib/config-array-factory.js:749:25)
      at _normalizeObjectConfigDataBody.next (<anonymous>)
      at ConfigArrayFactory._normalizeObjectConfigData (file:///Volumes/dev/(projectname)/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/lib/config-array-factory.js:694:20)
     - apps/(projectname)/jest.config.ts: Error: ● Validation Error:

    Module @nx/react/plugins/jest in the transform option was not found.
           <rootDir> is: /Volumes/dev/(projectname)/apps/(projectname)

    Configuration Documentation:
    https://jestjs.io/docs/configuration

Failure Logs

Package Manager Version

pnpm 10.1.0

Operating System

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

Additional Information

No response

@ktwbc ktwbc added the type: bug label Feb 2, 2025
@ktwbc
Copy link
Author

ktwbc commented Feb 2, 2025

I also cleared out everything and tried to use pnpx to create a new project, can't even get it created

➜ dev pnpx create-nx-workspace

NX Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · myorg
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · nextjs
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · ctest
✔ Would you like to use the App Router (recommended)? · No
✔ Would you like to use the src/ directory? · Yes
✔ Test runner to use for end to end (E2E) tests · none
✔ Default stylesheet format · scss
✔ Which CI provider would you like to use? · github

NX Creating your v20.4.0 workspace.

✔ Installing dependencies with pnpm
✔ Successfully created the workspace: myorg.
✔ Nx Cloud has been set up successfully
✖ Generating CI workflow

NX Failed to generate CI workflow

Exit code: 1
Log file: /Volumes/dev/myorg/error.log

➜ dev more /Volumes/dev/myorg/error.log

NX Failed to process project graph.

An error occurred while processing files for the @nx/eslint/plugin plugin.

  • apps/ctest/eslint.config.mjs: Cannot find package '@eslint/eslintrc' imported from /Volumes/dev/myorg/apps/ctest/eslint.config.mjs
    Did you mean to import @eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs?

/Volumes/dev/myorg/error.log (END)

@FrozenPandaz FrozenPandaz added the scope: linter Issues related to Eslint support in Nx label Feb 7, 2025
@jaysoo
Copy link
Member

jaysoo commented Feb 7, 2025

Looks like the issue happens specifically with pnpm@10 and ESLint. We'll look into it.

In the meantime you could pass --workspaces which will opt you into pnpm workspaces, etc. And also comes with more prompts, so you can skip eslint.

pnpx create-nx-workspace --workspaces

@ktwbc
Copy link
Author

ktwbc commented Feb 8, 2025

Looks like the issue happens specifically with pnpm@10 and ESLint. We'll look into it.

In the meantime you could pass --workspaces which will opt you into pnpm workspaces, etc. And also comes with more prompts, so you can skip eslint.

pnpx create-nx-workspace --workspaces

tried that, also did not work

test git:(master) ✗ pnpx create-nx-workspace --workspaces
Packages: +56
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 56, reused 55, downloaded 1, added 56, done

NX Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · mytest
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · nextjs
✔ Application name · mytest
✔ Would you like to use the App Router (recommended)? · No
✔ Would you like to use the src/ directory? · Yes
✔ Which unit test runner would you like to use? · jest
✔ Test runner to use for end to end (E2E) tests · playwright
✔ Default stylesheet format · scss
✔ Would you like to use ESLint? · Yes
✔ Would you like to use Prettier for code formatting? · Yes
✔ Which CI provider would you like to use? · github

NX Creating your v20.4.2 workspace.

✔ Installing dependencies with pnpm
✔ Successfully created the workspace: mytest.
✔ Nx Cloud has been set up successfully
✖ Generating CI workflow

NX Failed to generate CI workflow

Exit code: 1
Log file: /Volumes/dev/test/mytest/error.log

➜ test git:(master) ✗ more /Volumes/dev/test/mytest/error.log

NX Failed to process project graph.

An error occurred while processing files for the @nx/eslint/plugin plugin.

  • apps/mytest/eslint.config.mjs: Cannot find package '@eslint/eslintrc' imported from /Volumes/dev/test/mytest/apps/mytest/eslint.config.mjs
    Did you mean to import @eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs?

however skipping eslint on a subsequent attempt did work

jaysoo added a commit that referenced this issue Feb 10, 2025
When flat compat is necessary, we don't ensure that `@eslint/eslintrc`
is installed, even though we import it. Depending on the package manager
and hoisting, it may still work, but as we see with pnpm v10, it is not
working without an explicit dependency in `package.json`.

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
Some app generators are broken is we use eslint compat.

## Expected Behavior
App generators should work.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #29845
jaysoo added a commit that referenced this issue Feb 12, 2025
When flat compat is necessary, we don't ensure that `@eslint/eslintrc`
is installed, even though we import it. Depending on the package manager
and hoisting, it may still work, but as we see with pnpm v10, it is not
working without an explicit dependency in `package.json`.

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
Some app generators are broken is we use eslint compat.

## Expected Behavior
App generators should work.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #29845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
4 participants