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

Nest Library generation fails in v20.0.0 #28404

Open
1 of 4 tasks
anthony-b-dev opened this issue Oct 11, 2024 · 11 comments
Open
1 of 4 tasks

Nest Library generation fails in v20.0.0 #28404

anthony-b-dev opened this issue Oct 11, 2024 · 11 comments
Assignees
Labels
scope: node Issues related to Node, Express, NestJS support for Nx type: bug

Comments

@anthony-b-dev
Copy link

Current Behavior

nx g @nx/nest:lib fgb-tenant

NX Generating @nx/nest:library

NX Could not find root flat config file

Expected Behavior

Library is generated

GitHub Repo

No response

Steps to Reproduce

  1. Run the nest library generation command

Nx Report

Node : 20.11.1
OS : win32-x64
Native Target : x86_64-windows
npm : 9.6.6

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/angular : 20.0.0
@nx/cypress : 20.0.0
@nx/devkit : 20.0.0
@nx/esbuild : 20.0.0
@nx/eslint-plugin : 20.0.0
@nx/express : 20.0.0
@nx/nest : 20.0.0
@nx/node : 20.0.0
@nx/web : 20.0.0
@nx/webpack : 20.0.0
typescript : 5.5.4

Community plugins:
@ngrx/component-store : 18.1.0
@ngrx/effects : 18.1.0
@ngrx/entity : 18.1.0
@ngrx/eslint-plugin : 18.1.0
@ngrx/operators : 18.1.0
@ngrx/router-store : 18.1.0
@ngrx/schematics : 18.1.0
@ngrx/store : 18.1.0
@ngrx/store-devtools : 18.1.0

Failure Logs

NX Generating @nx/nest:library

NX Could not find root flat config file

Package Manager Version

No response

Operating System

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

Additional Information

I have tried it with the directory command, nx g lib, and the fully expanded command. Nothing works.

@abdul-alim
Copy link

I am getting the below error while setting up nest project.

NX The "@nx/nest" plugin doesn't yet support the existing TypeScript setup

@gperdomor
Copy link
Contributor

This is related to #28322

@jaysoo jaysoo added the scope: node Issues related to Node, Express, NestJS support for Nx label Oct 14, 2024
@ndcunningham
Copy link
Contributor

Hey, thanks for reporting an issue.

To paraphrase from the above

As mentioned in Nx v20 blog post announcement, if you need to use other plugins while they don't support the new TS setup, please create an empty workspace with the apps preset: npx -y create-nx-workspace@latest --preset=apps

@JohnnyDevNull
Copy link

Same for Angular here:

Image

@bdahl1
Copy link

bdahl1 commented Nov 21, 2024

I've run into the same issue as Johnny. It seems like this only impacts the generator, so you could build the Library by hand and things would still work, correct? Is there a good example of that floating around somewhere using NX20 and Angular? At least as a workaround until the generator gets fixed?

@coreConvention
Copy link

Image

I am also seeing this issue currently. I have been unable find a way around it thus far.

@rajeev-john
Copy link

rajeev-john commented Nov 27, 2024

I also faced the same issue of @coreConvention. I got a work around for this by creating a file named eslint.config.js in the working directory. But still not sure if this is the right solution. Looking for the right fix for this

"@nx/angular": "20.1.0",
"@nx/cypress": "20.1.0",
"@nx/eslint": "20.1.0",
"@nx/eslint-plugin": "20.1.0",
"@nx/jest": "20.1.0",
"@nx/js": "20.1.0",
"@nx/workspace": "20.1.0",
"eslint": "9.14.0",
"nx": "20.1.0"

@kasir-barati
Copy link

kasir-barati commented Dec 10, 2024

Same here, nx g @nx/js:lib libs/shared --bundler=esbuild --linter=eslint --unitTestRunner=jest --verbose is upset about something since it throws this error message:

Error: Could not find root flat config file
    at getRootESLintFlatConfigFilename (/home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/@nx+eslint@20.2.1_@babel+traverse@7.26.4_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+help_p7jqooqyk4oi6p3v7733sbzc7e/node_modules/@nx/eslint/src/utils/flat-config.js:18:11)
    at lintConfigHasOverride (/home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/@nx+eslint@20.2.1_@babel+traverse@7.26.4_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+help_p7jqooqyk4oi6p3v7733sbzc7e/node_modules/@nx/eslint/src/generators/utils/eslint-file.js:179:164)
    at addLint (/home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/@nx+js@20.2.1_@babel+traverse@7.26.4_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+helpers@_hy7mt26ijjtzogm4skpywoo75e/node_modules/@nx/js/src/generators/library/library.js:292:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async libraryGeneratorInternal (/home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/@nx+js@20.2.1_@babel+traverse@7.26.4_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+helpers@_hy7mt26ijjtzogm4skpywoo75e/node_modules/@nx/js/src/generators/library/library.js:81:30)
    at async /home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/nx@20.2.1_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+helpers@0.5.15__@swc+types@0.1.17_t_w6pixw4aadyn6222jr5o5yzwvy/node_modules/nx/src/command-line/generate/generate.js:240:26
    at async handleErrors (/home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/nx@20.2.1_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+helpers@0.5.15__@swc+types@0.1.17_t_w6pixw4aadyn6222jr5o5yzwvy/node_modules/nx/src/utils/handle-errors.js:8:24)
    at async Object.handler (/home/kasir/projects/nestjs-materials/typeorm/node_modules/.pnpm/nx@20.2.1_@swc-node+register@1.10.9_@swc+core@1.10.1_@swc+helpers@0.5.15__@swc+types@0.1.17_t_w6pixw4aadyn6222jr5o5yzwvy/node_modules/nx/src/command-line/generate/command-object.js:13:22)

I am using Nx + PNPM + NestJS. I wanted to create a new library but instead I created a new bug. BTW I am not sure if this is somehow also related to this issue I opened here: #28991

Workaround

I renamed my root .eslintrc.json to eslint.config.js

@bdahl1
Copy link

bdahl1 commented Dec 11, 2024

Workaround

I renamed my root .eslintrc.json to eslint.config.js

That worked for me too... Very strange

@slyk
Copy link

slyk commented Dec 11, 2024

Workaround

I renamed my root .eslintrc.json to eslint.config.js

That worked for me too... Very strange

We can't just rename json to js. But this helped me: https://nx.dev/recipes/tips-n-tricks/flat-config
nx g @nx/eslint:convert-to-flat-config

It does the "renaming :)

@kasir-barati
Copy link

@bdahl1 It is happening because some code in Nx expects to find eslint.config.js or eslint.config.cjs:

export const eslintFlatConfigFilenames = [
'eslint.config.js',
'eslint.config.cjs',
];
export function getRootESLintFlatConfigFilename(tree: Tree): string {
for (const file of eslintFlatConfigFilenames) {
if (tree.exists(file)) {
return file;
}
}
throw new Error('Could not find root flat config file');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: node Issues related to Node, Express, NestJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests