Node module doubling
TS2322: Type 'QueryClient' is not assignable...
Types have separate declarations of a private property 'queryCache'.
This means TypeScript sees two different versions of QueryClient because it's being resolved:
once in your main app’s node_modules
once again inside .wasp/build/web-app/node_modules
They’re not the same instance, even if they are the same version — and TypeScript cannot match private fields (queryCache).
23 Replies
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You're correct: this error occurs when TypeScript detects two separate installations of the same package (here, QueryClient from React Query), leading to type incompatibility—especially for types with private fields. This happens because both your main app's node_modules and .wasp/build/web-app/node_modules contain their own copies of the package, so TypeScript treats them as distinct types, even if the versions match.
This "double installation" issue is a known problem in Wasp's current structure. It can cause errors like the one you described, particularly with packages like React or React Query that rely on singleton instances or have types with private members. The root cause is that dependencies are sometimes installed both at the project root and inside generated code folders, leading to multiple, isolated node_modules trees. This is discussed in detail in Wasp's GitHub issues, where users have reported similar problems with React and other dependencies, resulting in errors and even white screens due to conflicting instances. Temporary workarounds include deleting redundant node_modules folders and Vite's cache, but a more robust solution is being considered, such as using npm workspaces or improving how dependencies are resolved and installed during the build process Solve double installation issue in restructuring.
In summary: TypeScript cannot reconcile types from two different node_modules trees, even if the code is identical, because private fields make the types incompatible. This is a known Wasp issue, and the team is exploring solutions to prevent or detect such double installations in the future. For now, ensure only one node_modules tree is used for shared dependencies to avoid these type errors.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Sven, 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?
howc an i solve these issues
@kapa.ai how do i reset or rebuild my wasp?
Let me check the knowledge base for you again. One moment! :books:
----------------------
To reset or rebuild your Wasp project, you should use the following commands:
1. Run
This is similar to doing a full reset or a "turn it off and on again" for your Wasp project. 2. After cleaning, run
- Run
wasp clean
in your project directory. This command will:
- Delete the .wasp/
directory (which contains generated code and build artifacts)
- Delete the node_modules/
directory (removing all installed npm packages)
This is similar to doing a full reset or a "turn it off and on again" for your Wasp project. 2. After cleaning, run
wasp start
to recompile and reinstall everything. This will regenerate the necessary files and reinstall dependencies, giving you a fresh build of your project.
This process is recommended whenever you encounter strange build issues, dependency problems, or want to ensure your project is in a clean state. For example, if you run into errors about missing modules or type mismatches, this is a good first step to resolve them CLI Reference: Project Commands, Discord: clean and start advice.
Summary:- Run
wasp clean
- Then run wasp start
This will reset and rebuild your Wasp project from scratch.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Sven, 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?Hey @Sven , did you manage to solve it?
Did
wasp clean
and wasp start
work?@Sven Same problem 😦 Any fix?
wasp clean and delete packagelock.json
Hey, does
wasp clean
+ delete package-lock.json
work?Not working for me. Did anyone find a solution?
@kapa.ai what else can we do if nothing works?
Let me check the knowledge base for you again. One moment! :books:
----------------------
If running
Carefully review the error messages in your terminal and browser console. Sometimes, the error will point to a missing dependency or a specific misconfiguration. 2. Check for Multiple
Double installations of dependencies (for example, both in your project root and inside
If you have a
Sometimes, running
Run
If you still can't resolve the problem, search for your error message in the Wasp Discord or GitHub issues. Others may have encountered and solved the same issue. If none of these steps work, please provide the exact error message and details about your setup (Wasp version, OS, steps to reproduce) when seeking help. This will make it easier for the community or maintainers to assist you. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @sig_hansen, 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?
wasp clean
followed by wasp start
does not resolve your issue, here are a few additional steps that have been discussed in the Wasp community and issue trackers:
1. Check for Errors in the Console/Logs:Carefully review the error messages in your terminal and browser console. Sometimes, the error will point to a missing dependency or a specific misconfiguration. 2. Check for Multiple
node_modules
Folders:Double installations of dependencies (for example, both in your project root and inside
.wasp/build/web-app/node_modules
) can cause issues. Try deleting all node_modules
folders manually and then running wasp start
again. This has been a known source of problems, especially with packages like React or React Query, leading to type errors and runtime issues Solve double installation issue in restructuring.
3. Check for Parent package.json
Files:If you have a
package.json
in a parent directory (above your Wasp project), it can interfere with dependency resolution, especially for packages like Prisma. Make sure your Wasp project is not nested inside another Node.js project, or temporarily move it out to test if that resolves the issue If there is package.json above the Wasp project, prisma version from it will be used.
4. Run npm install
Manually:Sometimes, running
npm install
in your project directory (or in the generated .wasp
subdirectories) can help resolve missing dependencies.
5. Check Wasp Version:Run
wasp version
to ensure you are using a supported and up-to-date version. Some bugs have been fixed in newer releases, so upgrading Wasp may resolve your issue Wasp apps inside NPM projects don't work.
6. Review Community Discussions:If you still can't resolve the problem, search for your error message in the Wasp Discord or GitHub issues. Others may have encountered and solved the same issue. If none of these steps work, please provide the exact error message and details about your setup (Wasp version, OS, steps to reproduce) when seeking help. This will make it easier for the community or maintainers to assist you. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @sig_hansen, 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?
This is the error message:
Also im on wasp version 0.16.3. and tried to manually install via
npm install
and to remove all node_modules/.@toticozeni FYI ^^
I was able to fix it by removing the tanstack dependency from the app/node_modules folder before running vite build.
I'm also getting this but on a github action:
Is the issue is resolved by upgrading to Wasp 0.16.5?
curl -sSL https://get.wasp.sh/installer.sh | sh
Ok I'm on 0.16.3. I'll try it out.
Let me know if it works
I switched over to the wasp ts config file and have the
wasp-config
entry in my dev deps in package.json. Does that need to get updated to 0.16.5 as well? @kapa.aiLet me check the knowledge base for you again. One moment! :books:
----------------------
I'm sorry, but the knowledge sources do not contain any information about a
wasp-config
package or whether it needs to be updated to version 0.16.5. There is also no explicit documentation about managing a wasp-config
entry in your devDependencies
or its relationship to the Wasp version. If this is a package or convention outside of official Wasp documentation, I cannot provide a definitive answer based on the provided sources.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @hadanator, 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?@hadanator oh yes you should! Try running
wasp ts-setup
, does that update it correctly?
This part is so manual because this is still experimental feature -> once we stabilize it (soon), you won't have to deal with these details or look at that path in the package.json.Oh ok great. I had ran it before I updated the wasp version on my machine, but after running it after, it updated the version correctly. Trying it again on github actions.
It failed running the action, but I did have one more reference to the local 0.16.3 stuck in the package-lock.json, probably from running ts-setup previously. I pushed up the change to package-lock removing that, but it still broke with this error:
I don't have anywhere else in my codebase with 0.16.3 referenced
Wohooo @hadanator, you just became a Waspeteer level 3!
Oop just kidding, forgot to update the action yaml file to wasp 0.16.5
Awesome!