Cannot find module
Hello i am trying to run a migration to an existing project that is newly installed on my laptop and keep getting errors such as:
[ Wasp ] auth/useAuth.ts(8,32): error TS2307: Cannot find module '@tanstack/react-query' or its corresponding type declarations.
[ Wasp ] client/operations/hooks.ts(9,8): error TS2307: Cannot find module '@tanstack/react-query' or its corresponding type declarations.
[ Wasp ] client/operations/queryClient.ts(1,48): error TS2307: Cannot find module '@tanstack/react-query' or its corresponding type declarations.
[ Wasp ] client/test/vitest/helpers.tsx(7,50): error TS2307: Cannot find module '@tanstack/react-query' or its corresponding type declarations.
❌ --- [Error] Your wasp project failed to compile: -------------------------------
- SDK build failed with exit code: 2
❌ --- [Error] Compilation of wasp project failed: --------------------------------
1 errors found
15 Replies
Hi @Yumyum. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It looks like you're encountering module resolution errors when trying to run a migration on your Wasp project. This is a common issue that can happen when dependencies aren't properly installed or when there are conflicts between different installations of the same package.
The error messages indicate that your project can't find the
@tanstack/react-query
package, which is a dependency used by Wasp's SDK.
Here are a few solutions you can try:
1. Clean and restart your project:
This will delete the .wasp
folder and node_modules
, then reinstall everything from scratch, which often resolves module resolution issues Discord support thread.
2. If that doesn't work, you might be experiencing a "double installation" issue, where React or other packages are installed in multiple locations, causing conflicts. This can happen especially in nested project structures or when a Wasp app is inside an NPM project GitHub Issue #1792.
3. Check if your project is inside another NPM project (i.e., if there's a package.json
file or node_modules
directory higher up in your file tree). This can cause module resolution conflicts GitHub Issue #1792.
4. Make sure you're running the Wasp compiler with wasp start
before trying to use any of the wasp/*
packages, as the SDK needs to be compiled first Discord support thread.
If the issue persists after trying these solutions, you might want to check your Wasp version with wasp version
to ensure you're using a compatible version for your project.
Let me know if any of these solutions work for you!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Yumyum, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Can you share your
package.json
file here?Yes, i removed some things but now get this
Please run
npm ls react
in the root of your project 🙂 + npm ls @tanstack/react-query
and share the output here/mnt/c/users/ayman/desktop/booking/Rezervera-main
└── (empty)
/mnt/c/users/ayman/desktop/booking/Rezervera-main
└── (empty)
Make sure to run in the Wasp project root, that might be the
app
dir if you are using Open SaasHere you go 🙂
npm ls @tanstack/react-query
[email protected] /mnt/c/users/ayman/desktop/booking/Rezervera-main/app
└─┬ [email protected] -> ./.wasp/out/sdk/wasp
└── @tanstack/[email protected]
The logs don't give any interesting info. Try doing
wasp clean
+ rm package-lock.json
and let's see what happensmy wasp clean is pretty slow for some reason, I'll be back in 15min or so
Wohooo @Yumyum, you just became a Waspeteer level 1!
Maybe you are using the Windows file system vs. Linux file system, I'd recommend following this guide to setting up WSL2 https://wasp.sh/blog/2023/11/21/guide-windows-development-wasp-wsl
that worked, thanks alot
I'll do this aswell I guess