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

unable to find tsconfig.base.json or tsconfig.json #20574

Closed
1 of 4 tasks
CGQAQ opened this issue Dec 5, 2023 · 9 comments
Closed
1 of 4 tasks

unable to find tsconfig.base.json or tsconfig.json #20574

CGQAQ opened this issue Dec 5, 2023 · 9 comments

Comments

@CGQAQ
Copy link
Contributor

CGQAQ commented Dec 5, 2023

Current Behavior

D:\Code\Personal\2b\web>nx g @nx/next:app core --verbose   

 >  NX   Unable to resolve @nx/next:app.

   unable to find tsconfig.base.json or tsconfig.json

Error: Unable to resolve @nx/next:app.
unable to find tsconfig.base.json or tsconfig.json
    at getGeneratorInformation (D:\Code\Personal\2b\.nx\installation\node_modules\nx\src\command-line\generate\generator-utils.js:39:15)
    at D:\Code\Personal\2b\.nx\installation\node_modules\nx\src\command-line\generate\generate.js:218:248
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleErrors (D:\Code\Personal\2b\.nx\installation\node_modules\nx\src\utils\params.js:9:16)

Expected Behavior

create successfully

GitHub Repo

No response

Steps to Reproduce

  1. nx g @nx/next:app core --verbose

Nx Report

Node   : 20.9.0
OS     : win32-x64
npm    : 10.1.0

nx (global)  : 17.1.3
nx           : 17.1.3
@nrwl/tao    : 17.1.3

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@CGQAQ CGQAQ added the type: bug label Dec 5, 2023
@mandarini mandarini added the os: windows Issues that can only be replicated on Windows label Dec 7, 2023
@mandarini
Copy link
Member

Hi there @CGQAQ ! I cannot reproduce on macos, I added the windows label so that we try it on windows!

@mandarini
Copy link
Member

Oh, also, it would be super helpful if you could provide a minimum reproduction repository!

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Dec 13, 2023

repro repo: https://github.com/CGQAQ/nx-20574-repro

@mandarini
Copy link
Member

mandarini commented Dec 13, 2023

@CGQAQ hmm I do not see a package.json file in your project. if you want to use our @nx/next package, or any of our packages really, you first have to install them: https://nx.dev/nx-api/next#setting-up-nextjs

@mandarini
Copy link
Member

So, I have some updated info @CGQAQ after talking with @AgentEnder who knows more about this setup! :)

First, you can, indeed, run generators from plugins listed in your nx.json installation section without a package.json present in your repo root. However, none of our first-party generators are written with this in mind, including @nx/next which you're trying to use.

Second, you don't seem to have the @nx/next plugin installed inside the nx.json[installation] block, so its not installed there.

Third, JavaScript based projects don't really benefit from .nx install, so maybe you should consider scaffolding your repo in another way, maybe using create-nx-workspace: https://nx.dev/getting-started/installation

Let me know if these things help!

@CGQAQ
Copy link
Contributor Author

CGQAQ commented Dec 14, 2023

The thing is I have a project that is NOT pure js, it's half Rust half js, so first thing I did is look up docs, and found installing-nx-into-an-existing-repository, then I search 'nextjs nx' and found this, and I don't want package.json in my root, so I skipped the first step and directly ran nx g @nx/next:lib my-new-lib, after doing these:

  1. npm init -y
  2. npm install --save-dev @nx/next
  3. nx g @nx/next:app my-new-app

it works now, so I guess I should close the issue, thanks

@CGQAQ CGQAQ closed this as completed Dec 14, 2023
@CGQAQ
Copy link
Contributor Author

CGQAQ commented Dec 14, 2023

However, none of our first-party generators are written with this in mind, including @nx/next which you're trying to use.

@mandarini The thing I still not quite get is that if none of your generators support this, why you generate in this way by default in this command, it's very confusing. I think you should generate the project the way you support, so I will reopen this.

and also

NX Unable to resolve @nx/next:app.

unable to find tsconfig.base.json or tsconfig.json

👆 the error is confusing as well, should be missing '@nx/next' devDep in your project, thats not supported

@CGQAQ CGQAQ reopened this Dec 14, 2023
@AgentEnder AgentEnder removed the os: windows Issues that can only be replicated on Windows label Dec 14, 2023
@AgentEnder
Copy link
Member

Hey @CGQAQ, there's a few things to break down here:

  • The error is confusing, its something that changed because when we try to resolve plugins if it fails then we look for local plugins, which requires the tsconfigs. This should be updated.

  • The .nx setup is intended mainly for repos that don't use generators to get things up and running. The only way it gets generated when running nx init, is if you pick to initialize nx inside a folder that doesn't have a package.json in it. This typically matches the assumption that you won't be running generators which would add a package.json there.

I hope this clears things up. I'll work on cleaning the error message up, but lets keep the issue closed since you were able to correct the configuration in your repo and we can work on clearing docs up as time goes on.

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants