wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
12.73k stars 1.13k forks source link

tsconfig.json(2,14): error TS6053: File '@tsconfig/node18/tsconfig.json' not found #2085

Open sammo opened 3 weeks ago

sammo commented 3 weeks ago

Hi -

I'm trying to start a new wasp project but running into this error on wasp db migrate-dev command.

Do you know what the issue could be?

āœ… --- Database successfully set up. ----------------------------------------------

šŸ --- Building SDK... ------------------------------------------------------------

[ Wasp ] tsconfig.json(2,14): error TS6053: File '@tsconfig/node18/tsconfig.json' not found. [ Wasp ] ../../../../node_modules/@testing-library/jest-dom/types/jest.d.ts(1,23): error TS2688: Cannot find type definition file for 'jest'. [ Wasp ] ../../../../node_modules/@testing-library/jest-dom/types/jest.d.ts(9,27): error TS2304: Cannot find name 'expect'. [ Wasp ] ../../../../node_modules/vitest/node_modules/vite/dist/node/index.d.ts(5,41): error TS2307: Cannot find module 'rollup/parseAst' or its corresponding type declarations. [ Wasp ] There are types at '.../mySaasApp/node_modules/vitest/node_modules/rollup/dist/parseAst.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

āŒ --- [Error] Your wasp project failed to compile: -------------------------------

āŒ --- [Error] Compilation of wasp project failed: --------------------------------

1 errors found

Martinsos commented 3 weeks ago

@sammo this seems quite weird!

It could help if you could provide following info: your OS, wasp version, node version, how did you start the project (I guess from open-saas? Doing wasp new -t saas?).

In the meantime, pls try running wasp clean and see if that helps -> if it does, let us know.

sammo commented 3 weeks ago

@Martinsos thanks for the quick reply. I'm using

I started the project by running these commands:

curl -sSL https://get.wasp-lang.dev/installer.sh | sh
wasp new mySaasApp -t todo-ts

I'll wasp clean

sammo commented 3 weeks ago

@Martinsos I just ran wasp new -t saas and it worked!

Thank you for the help.

Martinsos commented 3 weeks ago

Great @sammo ! I am still curious what caused the initial issue, do you have any idea? How did you create the project first time?

EDIT: Sorry, I missed the message above, I see now how you started the project! It is important to notice that you started Wasp from different template now -> saas is much richer than todo-ts. However, todo-ts should also work!

Would you mind trying creating project with wasp new myTodoApp -t todo-ts and seeing if you get the error again or if it is again? If it happens again, we will make sure to look deeper into it. I did try it just to be sure on my machine right now, but it works for my setup at the moment, for todo-ts.

sammo commented 3 weeks ago

@Martinsos I found out from my .zsh_history this error was raised by wasp db migrate-dev

That's how I replicated it

wasp new mySaasApp2 -t todo-ts
cd mySaasApp2
wasp db migrate-dev

And I got this error

šŸ --- Compiling wasp project... --------------------------------------------------

[  Wasp  ] Starting npm install
[  Wasp  ] Still installing npm dependencies!
[  Wasp  ] Installation going great - we'll get there soon!
[  Wasp !] npm WARN deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead
[  Wasp !] npm WARN deprecated domexception@4.0.0: Use your platform's native DOMException instead
[  Wasp  ] 
[  Wasp  ] added 462 packages, and audited 463 packages in 18s
[  Wasp  ] 
[  Wasp  ] 101 packages are looking for funding
[  Wasp  ]   run `npm fund` for details
[  Wasp  ] 
[  Wasp  ] 2 moderate severity vulnerabilities
[  Wasp  ] 
[  Wasp  ] Some issues need review, and may require choosing
[  Wasp  ] a different dependency.
[  Wasp  ] 
[  Wasp  ] Run `npm audit` for details.
[ Client ] Starting npm install
[ Server ] Starting npm install
[ Client ] 
[ Client ] added 117 packages, and audited 118 packages in 3s
[ Client ] 
[ Client ] 14 packages are looking for funding
[ Client ]   run `npm fund` for details
[ Client ] 
[ Client ] found 0 vulnerabilities
[ Server ] Still installing npm dependencies!
[ Server!] npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[ Server!] npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[ Server!] npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
[ Server ] 
[ Server ] added 372 packages, and audited 373 packages in 6s
[ Server ] 
[ Server ] 121 packages are looking for funding
[ Server ]   run `npm fund` for details
[ Server ] 
[ Server ] 4 moderate severity vulnerabilities
[ Server ] 
[ Server ] To address all issues (including breaking changes), run:
[ Server ]   npm audit fix --force
[ Server ] 
[ Server ] Run `npm audit` for details.
āœ… --- Successfully completed npm install. ----------------------------------------

šŸ --- Setting up database... -----------------------------------------------------

[   Db  !] Error: P1003
[   Db  !] 
[   Db  !] Database dev.db does not exist at /.../mySaasApp2/.wasp/out/db/./dev.db
[   Db  !] 
[   Db   ] Environment variables loaded from .env
[   Db   ] Prisma schema loaded from ../db/schema.prisma
[   Db   ] 
[   Db   ] āœ” Generated Prisma Client (4.16.2 | library) to ./../../../node_modules/@prisma/client in 63ms
[   Db   ] You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
[   Db   ] ```
[   Db   ] import { PrismaClient } from '@prisma/client'
[   Db   ] const prisma = new PrismaClient()
[   Db   ] ```
āœ… --- Database successfully set up. ----------------------------------------------

šŸ --- Building SDK... ------------------------------------------------------------

[  Wasp  ] tsconfig.json(2,14): error TS6053: File '@tsconfig/node18/tsconfig.json' not found.
[  Wasp  ] ../../../../node_modules/@testing-library/jest-dom/types/jest.d.ts(1,23): error TS2688: Cannot find type definition file for 'jest'.
[  Wasp  ] ../../../../node_modules/@testing-library/jest-dom/types/jest.d.ts(9,27): error TS2304: Cannot find name 'expect'.
[  Wasp  ] ../../../../node_modules/vitest/node_modules/vite/dist/node/index.d.ts(5,41): error TS2307: Cannot find module 'rollup/parseAst' or its corresponding type declarations.
[  Wasp  ]   There are types at '/.../mySaasApp2/node_modules/vitest/node_modules/rollup/dist/parseAst.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

āŒ --- [Error] Your wasp project failed to compile: -------------------------------

- SDK build failed with exit code: 2

āŒ --- [Error] Compilation of wasp project failed: --------------------------------

1 errors found
Martinsos commented 3 weeks ago

Awesome thanks! Just to confirm, this are not logs from the first time, you actually managed to replicate this again?

I wonder if this has something to do with node 18 hm, we will be looking into it.

Martinsos commented 3 weeks ago

One more user reported the same issue: https://github.com/wasp-lang/open-saas/issues/173 .

@aliammari1, it could help if you could provide following info: your OS, wasp version, node version, how did you start the project (open saas? specific template? Mage?).

In the meantime, pls try running wasp clean and see if that helps -> if it does, let us know.

Martinsos commented 3 weeks ago

And here is the third report: https://github.com/wasp-lang/wasp/issues/2091 !

Super short info from it:

OS: Linux 6.1.0-21-amd64 Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux Browser: chrome Version: chrome 125.0.6422.141 Wasp: 0.13.2 Node v18.19.0

wasp clean didn't help them.


Interesting data so far is:

  1. Both reports are from Ubuntu (we don't know about thrid report yet).
  2. Error is mentioning node18 and two of the users reported using node 18.

I this this is very likely connected to node 18, not sure how yet or why it started happening now. Ubuntu is probably not the cause, but probably the "delivery method", in the sense that the users are using a version of Ubuntu that comes with node 18 by default.

Martinsos commented 3 weeks ago

@grsh50 , could you please try switching to node 20 (e.g. using nvm) and try running Wasp again?

@aliammari1 which node version are you using? If you are using 18, could you also try switching to 20 and tell us if that helps?

grsh50 commented 3 weeks ago
grosh@buh:~/Documents/src/repo/newWasp/myTodoApp$ wasp db migrate-dev

šŸ --- Compiling wasp project... --------------------------------------------------

āœ… --- Successfully completed npm install. ----------------------------------------

šŸ --- Setting up database... -----------------------------------------------------

[   Db  !] Error: P1003
[   Db  !] 
[   Db  !] Database dev.db does not exist at /home/grosh/Documents/src/repo/newWasp/myTodoApp/.wasp/out/db/./dev.db
[   Db  !] 
āœ… --- Database successfully set up. ----------------------------------------------

šŸ --- Building SDK... ------------------------------------------------------------

[  Wasp  ] tsconfig.json(2,14): error TS6053: File '@tsconfig/node18/tsconfig.json' not found.
[  Wasp  ] ../../../../node_modules/@testing-library/jest-dom/types/jest.d.ts(1,23): error TS2688: Cannot find type definition file for 'jest'.
[  Wasp  ] ../../../../node_modules/@testing-library/jest-dom/types/jest.d.ts(9,27): error TS2304: Cannot find name 'expect'.
[  Wasp  ] ../../../../node_modules/vitest/node_modules/vite/dist/node/index.d.ts(5,41): error TS2307: Cannot find module 'rollup/parseAst' or its corresponding type declarations.
[  Wasp  ]   There are types at '/home/grosh/Documents/src/repo/newWasp/myTodoApp/node_modules/vitest/node_modules/rollup/dist/parseAst.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

āŒ --- [Error] Your wasp project failed to compile: -------------------------------

- SDK build failed with exit code: 2

āŒ --- [Error] Compilation of wasp project failed: --------------------------------

1 errors found
grosh@buh:~/Documents/src/repo/newWasp/myTodoApp$ node --version
v20.14.0
Martinsos commented 3 weeks ago

Ok so it also happens with node 20, didn't expect that! Thanks, we will be looking into this in the following days and will be posting updates here!

Martinsos commented 3 weeks ago

Note for devs: we currently always go with @tsconfig/node18, even if people use node 20 or later, because we have this 18 currently on th lower limit for what Wasp supports. In the future we will be basing it on engines in package.json.

Martinsos commented 3 weeks ago

Note for devs: I tried replicating this on my machine but failed, all works so far. Specifically, I reinstalled latest version of Wasp and ran wasp new MyTestApp -t todo-ts and then wasp db migrate-dev. I also tried cleaning the whole npm cache with npm cache clean --force to simulate a more "fresher" situation, but that also didn't help, it still works. I did this first test with node 20, I tried doing it also with node 18.19 but also couldn't replicate. This is on Arch Linux.

aliammari1 commented 3 weeks ago

@grsh50 , could you please try switching to node 20 (e.g. using nvm) and try running Wasp again?

@aliammari1 which node version are you using? If you are using 18, could you also try switching to 20 and tell us if that helps?

thank you sir, the problem was my node version. I updated it from 18 to 20 and it worked

Martinsos commented 3 weeks ago

@grsh50 , could you please try switching to node 20 (e.g. using nvm) and try running Wasp again? @aliammari1 which node version are you using? If you are using 18, could you also try switching to 20 and tell us if that helps?

thank you sir, the problem was my node version. I updated it from 18 to 20 and it worked

Thanks for letting me know!

This does make things even more complex though hah, because one user got it fixed by installing another template, while one user fixed it with using another node version, and finally none of these helped third user! Hm. Almost sounds like it is getting fixed randomly.

grsh50 commented 3 weeks ago

Thank you for your support! :)

I ran wasp new todo -t todo-ts, and it worked.

This time, compiling the Wasp project took longer, but the SDK build was almost instant.

Could the issue be related to the Node version used to create the new project? The previous logs were from a project created on Node 18.19, and only the wasp db migrate-dev command was executed on Node 20.14.

Update: The MAGE app now runs.

Martinsos commented 3 weeks ago

Thank you for your support! :)

I ran wasp new todo -t todo-ts, and it worked.

This time, compiling the Wasp project took longer, but the SDK build was almost instant.

Could the issue be related to the Node version used to create the new project? The previous logs were from a project created on Node 18.19, and only the wasp db migrate-dev command was executed on Node 20.14.

Update: The MAGE app now runs.

Oh that's an interesting hypothesis indeed!

AHa, wait, now even the older app runs? Ok, now we have no idea again what is causing this :D.

Is there any way you can replicate the initial problem again? For example going to node 18 again, and trying to run that Mage app, or maybe new app based on todo-ts?

@sammo above managed to replicate it doing wasp new MyCoolApp -t todo-ts with node 18, if you can also do that consistently, that gives us something solid to work from.

Martinsos commented 2 weeks ago

One more report: https://discord.com/channels/686873244791210014/1250815248395669504/1250815248395669504 .

User was using node 18, but new data point is that they managed to fix it by adding

 "devDependencies": {
    "@tsconfig/node18": "latest",

to their package.json.

What also worked was switching to node 20, then that dev dependency was not needed, same like other users.

grsh50 commented 2 weeks ago

I ran some test builds with todo's and saas templates on node versions 18.19.0 and 18.19.1 and everything works fine.

Update: I tried the case I mentioned earlier - changing the node version after creating the template. Everything works fine.

$ node --version
v18.19.0
$ wasp new
$ nvm use 20.14.0
$ wasp db start
$ wasp db migrate-dev
Martinsos commented 2 weeks ago

I ran some test builds with todo's and saas templates on node versions 18.19.0 and 18.19.1 and everything works fine.

Ah come on :)! I am kidding, thanks a lot, but am still surprised by inconsistency of this bug. Still, we will figure it out, one way or another!

infomiho commented 6 days ago

This is the only similar issue I found while searching around the internet: https://github.com/TypeStrong/ts-node/issues/2076

It seems to be related to ts-node which jest uses under the hood to resolve the tsconfig.json. This was caused by some internal API changes in TS 5.2+ version. I'm really not sure if we have similar issues as reported there. I've tested also on Ubuntu with Node 18 and couldn't reproduce it.

Martinsos commented 6 days ago

This is the only similar issue I found while searching around the internet: TypeStrong/ts-node#2076

It seems to be related to ts-node which jest uses under the hood to resolve the tsconfig.json. This was caused by some internal API changes in TS 5.2+ version. I'm really not sure if we have similar issues as reported there. I've tested also on Ubuntu with Node 18 and couldn't reproduce it.

It being triggered by changes in TS version makes sense, as it started happened suddenly, that is very likely the cause! We need to pin down that TS version tighter.

I would still like to better understand the exact thing that happens, but I think we have a good bet what is the cause now.

sodic commented 1 day ago

It seems to be related to ts-node which jest uses under the hood to resolve the tsconfig.json.

That's not it (at least I think it isn't). ts-node is nowhere to be found in node_modules. From what I see, Jest isn't using it.

@infomiho What made you think we were using ts-node? If it was this comment, it was probably a misunderstanding - the comment talks about Jest TS configuration files (not tsconfig.json files).

Regardless, I tried installing ts-node both globally and in the repo, with the hopes of jest using it if it's available, but no luck. Unless I missed something, I think it's safe to say this isn't related to ts-node.

I'll now try reproducing it with different versions of TypeScript.

sodic commented 10 hours ago

Next time this happens, we should ask our users for a zip of their projects (or at least their package.json and package-lock.json files).

Martinsos commented 7 hours ago

@sodic it is not any kind of special projects though, they say above they merely had it happen on creating a new Wasp project from the template. So maybe package-lock.json files would offer something unique for their installation, but the rest, including package.json, shouldn't be anything unique. Notice that even if they share their package-lock.json, it still won't capture what was installed for the purposes of the framework code (or will it?).

Martinsos commented 4 hours ago

Some quick analysis of information we have so far:

It seems that there is a situation, when using node 18, that results in tsconfig/node18 not getting installed, and then stuff fails. And it seems that to get out of it, you need to shake things up a bit, and the most efficient way is to switch to node 20, but it seems like sometimes something else also helps.

sodic commented 4 hours ago

Ideas:

Other thoughts:

One problem I noticed: