wasp icon indicating copy to clipboard operation
wasp copied to clipboard

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

Open sammo opened this issue 1 year ago • 22 comments

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: -------------------------------

  • SDK build failed with exit code: 2

❌ --- [Error] Compilation of wasp project failed: --------------------------------

1 errors found

sammo avatar Jun 06 '24 12:06 sammo

Edit: see how to solve this here: https://github.com/wasp-lang/wasp/issues/2085#issuecomment-2276137271


@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.

Martinsos avatar Jun 06 '24 13:06 Martinsos

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

  • ubuntu 24.04
  • wasp 0.13.2
  • node 18.9.1

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 avatar Jun 06 '24 16:06 sammo

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

Thank you for the help.

sammo avatar Jun 06 '24 16:06 sammo

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.

Martinsos avatar Jun 06 '24 17:06 Martinsos

@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 [email protected]: Use your platform's native atob() and btoa() methods instead
[  Wasp !] npm WARN deprecated [email protected]: 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 [email protected]: 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 [email protected]: Rimraf versions prior to v4 are no longer supported
[ Server!] npm WARN deprecated [email protected]: 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

sammo avatar Jun 06 '24 18:06 sammo

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 avatar Jun 06 '24 19:06 Martinsos

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 avatar Jun 10 '24 11:06 Martinsos

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 avatar Jun 10 '24 11:06 Martinsos

@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?

Martinsos avatar Jun 10 '24 11:06 Martinsos

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

grsh50 avatar Jun 10 '24 12:06 grsh50

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 avatar Jun 10 '24 14:06 Martinsos

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 avatar Jun 10 '24 14:06 Martinsos

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.

Martinsos avatar Jun 10 '24 14:06 Martinsos

@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

aliammari1 avatar Jun 10 '24 14:06 aliammari1

@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.

Martinsos avatar Jun 10 '24 17:06 Martinsos

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.

grsh50 avatar Jun 11 '24 07:06 grsh50

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 avatar Jun 12 '24 14:06 Martinsos

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.

Martinsos avatar Jun 13 '24 16:06 Martinsos

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

grsh50 avatar Jun 13 '24 23:06 grsh50

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!

Martinsos avatar Jun 14 '24 12:06 Martinsos

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.

infomiho avatar Jun 27 '24 08:06 infomiho

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.

Martinsos avatar Jun 27 '24 09:06 Martinsos

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 avatar Jul 02 '24 15:07 sodic

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).

sodic avatar Jul 03 '24 09:07 sodic

@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 avatar Jul 03 '24 12:07 Martinsos

Some quick analysis of information we have so far:

  • OS: Ubuntu, Debian, unknown, unknown
  • everybody had the issue due to creating a Wasp project with node 18.
  • different fixes that worked for people:
    • wasp clean && wasp new -t saas while staying on node 18
    • switching to node 20 and running the project again
    • creating project again with node 20 and then running it
    • adding tsconfig/node18 directly to package.json as a dev dep
  • once things get working for people, they continue working

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.

Martinsos avatar Jul 03 '24 15:07 Martinsos

Ideas:

  • The file most likely really is missing (i.e., it's not an error in the code trying to find the file) because:
    1. TSC crashes immediately after not being able to find the file.
    2. One user added it to devDependencies at the root of the project, which fixed the problem immediately.
  • Our best guess is that, sometimes, the @tscofig/node18 doesn't get installed to top-level node_modules.

Other thoughts:

  • The SDK lists tsconfig/node18 as a devDependency. How come it's ever installed (devDependencies shouldn't be installed for packages)? Is it because it's a linked package?
  • The server also lists tsconfig/node18 as a devDependency. I forgot how NPM install works if the package is already installed in scope (I think it just duplicates it)?
  • The central question: Why do we ever get tsconfig/node18 installed in top-level node_modules. Do we just get lucky that some other package includes it as a regular dependency? Does NPM install devDependencies for SDK? Does this also happen in production?
  • #1653 might fix this problem.

One problem I noticed:

  • It seems we treat the SDK as a dependency (i.e., we don't run npm install inside its folder, it's installed indirectly through the root package.json), but we also treat it as a project (i.e., we build it). This is wrong and might be related to this problem. In other words, tsconfig/node18 is possibly being installed by luck.

sodic avatar Jul 03 '24 16:07 sodic

For users running into this: Please zip the entire project that exhibits this behavior and send it to us :)

sodic avatar Jul 04 '24 08:07 sodic

Hi I tried everything discussed here and nothing worked for me, so here is the download link to my project zip: https://mega.nz/file/YH1AgBLa#URDfK1Pyv0zpD8JcoZz-OqxJIx_o-YrMTjSjH3w7PO8

P.S: Sorry for the large file size, I just included everything for better diagnosis.

Moamethic avatar Jul 16 '24 20:07 Moamethic

@Moamethic Hey, thank you for the info. Could you share the error message you see?

infomiho avatar Jul 16 '24 20:07 infomiho