Build Error: QueryClient Type Conflict - Need Help with Production Deployment
Hey everyone! 👋
I'm running into a build error when trying to deploy my WASP project to production and could really use some help.
Issue: When I run
wasp build
, I'm getting this TypeScript error:
What I've tried:
- Running wasp clean
- Clearing node_modules and reinstalling
Has anyone encountered this type of QueryClient conflict before? Any suggestions on how to resolve this would be greatly appreciated!
Thanks in advance! 🙏12 Replies
Hi @mario.p. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This error is caused by having multiple instances of the @tanstack/query-core (react-query) library in your project—one in your main node_modules and another in the generated .wasp/build/web-app/node_modules. TypeScript treats types from these different locations as incompatible, even if they are the same version, because private properties like queryCache are not shared between them.
This is a known issue in the JavaScript/TypeScript ecosystem when dependencies are duplicated, often due to how build output and dependencies are managed.
What you can try:
1. Clean and Reinstall Everything
You already ran
The root cause is that the same package is being installed in two places. Wasp's build process should ideally deduplicate these dependencies, but sometimes it doesn't. There is an open issue about how Wasp handles dependencies and devDependencies, and the need to ensure the build can run without dev dependencies and with proper deduplication. This is still being worked on and may not be fully resolved yet Fix how we build generated project for production (dev deps). 3. Workaround: Force a Single Version
As a workaround, you can try to ensure that only one version of @tanstack/query-core is installed. You might use npm/yarn/pnpm dedupe commands, or check your package.json and lockfile for multiple versions. However, since Wasp generates code and manages dependencies internally, your ability to control this is limited. 4. Check for Related Issues and Updates
This type of error has come up in the community before, especially when the Wasp compiler or build process gets into a bad state. Running
If you are not on the latest version of Wasp, consider upgrading. Some dependency and build issues have been fixed in recent releases, especially around deployment and build output Discord thread: Failure to deploy client with Wasp CLI. Summary:
This is a dependency duplication issue between your main and generated node_modules. Try a full clean and reinstall, and consider upgrading Wasp if possible. If the problem persists, it may require a fix in Wasp's build tooling, which is being actively worked on. If you continue to have issues, please share your Wasp version and any customizations to your project structure, as this can help the community or maintainers provide more targeted advice. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mario.p, 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?
You already ran
wasp clean
and reinstalled node_modules, which is the right first step. Make sure you also delete the .wasp directory and all node_modules folders (including in subdirectories), then run wasp start
or wasp build
again. This sometimes resolves path conflicts if they were caused by a stale build or install.
2. Check for Dependency DeduplicationThe root cause is that the same package is being installed in two places. Wasp's build process should ideally deduplicate these dependencies, but sometimes it doesn't. There is an open issue about how Wasp handles dependencies and devDependencies, and the need to ensure the build can run without dev dependencies and with proper deduplication. This is still being worked on and may not be fully resolved yet Fix how we build generated project for production (dev deps). 3. Workaround: Force a Single Version
As a workaround, you can try to ensure that only one version of @tanstack/query-core is installed. You might use npm/yarn/pnpm dedupe commands, or check your package.json and lockfile for multiple versions. However, since Wasp generates code and manages dependencies internally, your ability to control this is limited. 4. Check for Related Issues and Updates
This type of error has come up in the community before, especially when the Wasp compiler or build process gets into a bad state. Running
wasp clean
and then wasp start
is the recommended fix, as confirmed by community members for similar "Cannot find module" or type mismatch errors Discord thread: Hey! Any ideas on some solutions to these errors?.
5. Upgrade WaspIf you are not on the latest version of Wasp, consider upgrading. Some dependency and build issues have been fixed in recent releases, especially around deployment and build output Discord thread: Failure to deploy client with Wasp CLI. Summary:
This is a dependency duplication issue between your main and generated node_modules. Try a full clean and reinstall, and consider upgrading Wasp if possible. If the problem persists, it may require a fix in Wasp's build tooling, which is being actively worked on. If you continue to have issues, please share your Wasp version and any customizations to your project structure, as this can help the community or maintainers provide more targeted advice. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mario.p, 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?
https://discord.com/channels/686873244791210014/1378216620203180127 may be relevant. Make sure you're fully updated to the newest patch which locked TanstackQuery to a version without the bug
Thanks @Zeke, how can I check if my wasp is fully updated to the newest patch? @kapa.ai any help here?
Let me check the knowledge base for you again. One moment! :books:
----------------------
To check if your Wasp CLI is fully updated to the newest patch, you can run:
This command will display your current Wasp version. The output will also include instructions for updating to the latest version, such as:
If you want to install a specific version, you can use:
You can check the list of valid versions (including the latest one) at:
https://github.com/wasp-lang/wasp/releases Currently, Wasp does not have a built-in command like wasp upgrade, but running the installer script as shown above will update you to the latest version if you are not already on it. The CLI does not automatically check for updates, so you need to compare your version with the latest release manually or follow the instructions provided after running wasp version Docs: CLI Reference. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mario.p, 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?
https://github.com/wasp-lang/wasp/releases Currently, Wasp does not have a built-in command like wasp upgrade, but running the installer script as shown above will update you to the latest version if you are not already on it. The CLI does not automatically check for updates, so you need to compare your version with the latest release manually or follow the instructions provided after running wasp version Docs: CLI Reference. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mario.p, 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?
@Zeke thanks for your support, your suggestions solved the problem 🙂
I was the one with the same error in that thread, so I'm glad to get new input on this issue, thanks @Zeke!
I just tried updating Wasp as @kapa.ai described, but now I get lots of build errors even for my local build. I was upgrading from 0.15.1, I ran which bumped me up to 0.16.5, but introduced the described error messages. Is there a way to not only update the CLI, but to add the necessary changes to the codebase as well?
Let me check the knowledge base for you again. One moment! :books:
----------------------
When you update the Wasp CLI to a new version (like from 0.15.1 to 0.16.5), your project codebase may also require changes to be compatible with the new Wasp version. Simply updating the CLI does not automatically migrate your project code—manual or semi-automated migration steps are often needed.
How to update your codebase for a new Wasp version:
1. Check for Migration Guides:
Wasp provides migration guides for major and breaking changes. For example, there is a detailed guide for migrating from 0.11.x to 0.12.x, which includes both CLI and codebase changes, as well as scripts to help automate some of the process. You should look for a migration guide specific to your upgrade path (e.g., 0.15.x to 0.16.x) on the Wasp documentation site or in the release notes. 2. Run Migration Scripts (if available):
For some upgrades, Wasp provides migration scripts (like
If there is no migration script for your specific upgrade, you may need to manually update your codebase according to the migration guide or release notes. This can include: - Updating project structure - Refactoring imports - Adapting to new APIs or breaking changes 4. Backup Before Migrating:
Always back up your project or commit your changes before starting the migration, so you can revert if something goes wrong. 5. Ask for Help:
If you get stuck, the Wasp team encourages you to ask for help on their Discord server Migration from 0.11.X to 0.12.X. Summary:
Updating the Wasp CLI does not automatically update your project codebase. You need to follow the migration guides and possibly run migration scripts to bring your codebase up to date with the new Wasp version. If a migration guide for your specific upgrade path is not available, check the release notes or ask the community for guidance. If you let me know the exact error messages or the changes between 0.15.1 and 0.16.5, I can help you find the relevant migration steps. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Dom, 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 provides migration guides for major and breaking changes. For example, there is a detailed guide for migrating from 0.11.x to 0.12.x, which includes both CLI and codebase changes, as well as scripts to help automate some of the process. You should look for a migration guide specific to your upgrade path (e.g., 0.15.x to 0.16.x) on the Wasp documentation site or in the release notes. 2. Run Migration Scripts (if available):
For some upgrades, Wasp provides migration scripts (like
npx wasp-migrate foo
for 0.11.x → 0.12.x) that help restructure your project and update imports. These scripts are referenced in the migration guides and can automate much of the tedious work Migration from 0.11.X to 0.12.X.
3. Manual Migration:If there is no migration script for your specific upgrade, you may need to manually update your codebase according to the migration guide or release notes. This can include: - Updating project structure - Refactoring imports - Adapting to new APIs or breaking changes 4. Backup Before Migrating:
Always back up your project or commit your changes before starting the migration, so you can revert if something goes wrong. 5. Ask for Help:
If you get stuck, the Wasp team encourages you to ask for help on their Discord server Migration from 0.11.X to 0.12.X. Summary:
Updating the Wasp CLI does not automatically update your project codebase. You need to follow the migration guides and possibly run migration scripts to bring your codebase up to date with the new Wasp version. If a migration guide for your specific upgrade path is not available, check the release notes or ask the community for guidance. If you let me know the exact error messages or the changes between 0.15.1 and 0.16.5, I can help you find the relevant migration steps. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Dom, 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?
Since I am working on some other things I downgraded back to 0.15.1 and my local project works fine again. @mario.p how did you solve your issues in detail? Just the CLI update or something else? Thanks in advance!
There's no automatic way to update the codebase, but the migration steps from 0.15.x to 0.16.x are pretty minimal
Migration from 0.15.X to 0.16.X | Wasp
What's new in 0.16.0?
Cool, glad I could help 😃
In local development everything worked fine and since my deployment infrastructure was Docker based and in my dockerfile I always download the latest version of WASP the only thing to do was to update my local WASP version on the prod server. Once downloaded the latest version of WASP everything worked just fine.
Thanks for the responses @genyus @mario.p , after correctly updating to Wasp 0.16.5 everything worked perfectly and I was able to deploy 😁