W
Wasp3mo ago
Sven

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
kapa.ai
kapa.ai3mo ago
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?
Sven
SvenOP3mo ago
howc an i solve these issues @kapa.ai how do i reset or rebuild my wasp?
kapa.ai
kapa.ai3mo ago
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 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.
$ wasp clean

$ wasp clean

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.
$ wasp start

$ wasp start

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?
toticozeni
toticozeni3mo ago
Hey @Sven , did you manage to solve it? Did wasp clean and wasp start work?
Johanfer
Johanfer3mo ago
@Sven Same problem 😦 Any fix?
Bruno Njeru
Bruno Njeru3mo ago
wasp clean and delete packagelock.json
toticozeni
toticozeni3mo ago
Hey, does wasp clean + delete package-lock.json work?
sig_hansen
sig_hansen3mo ago
Not working for me. Did anyone find a solution? @kapa.ai what else can we do if nothing works?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If running 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?
sig_hansen
sig_hansen3mo ago
This is the error message:
> tsc --build && vite build

src/index.tsx:25:28 - error TS2322: Type 'import("/home/paperless/paperlaas-frontend/app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient' is not assignable to type 'import("/home/paperless/paperlaas-frontend/app/.wasp/build/web-app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient'.
Types have separate declarations of a private property 'queryCache'.

25 <QueryClientProvider client={queryClient}>
~~~~~~

node_modules/@tanstack/react-query/build/lib/QueryClientProvider.d.ts:12:5
12 client: QueryClient;
~~~~~~
The expected type comes from property 'client' which is declared here on type 'IntrinsicAttributes & QueryClientProviderProps'


Found 1 error.
> tsc --build && vite build

src/index.tsx:25:28 - error TS2322: Type 'import("/home/paperless/paperlaas-frontend/app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient' is not assignable to type 'import("/home/paperless/paperlaas-frontend/app/.wasp/build/web-app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient'.
Types have separate declarations of a private property 'queryCache'.

25 <QueryClientProvider client={queryClient}>
~~~~~~

node_modules/@tanstack/react-query/build/lib/QueryClientProvider.d.ts:12:5
12 client: QueryClient;
~~~~~~
The expected type comes from property 'client' which is declared here on type 'IntrinsicAttributes & QueryClientProviderProps'


Found 1 error.
Also im on wasp version 0.16.3. and tried to manually install via npm install and to remove all node_modules/.
Vinny (@Wasp)
Vinny (@Wasp)3mo ago
@toticozeni FYI ^^
sig_hansen
sig_hansen3mo ago
I was able to fix it by removing the tanstack dependency from the app/node_modules folder before running vite build.
hadanator
hadanator3mo ago
I'm also getting this but on a github action:
src/index.tsx(25,28): error TS2322: Type 'import("/home/runner/work/project/project/app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient' is not assignable to type 'import("/home/runner/work/project/project/app/.wasp/build/web-app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient'.
Types have separate declarations of a private property 'queryCache'.
Error: Process completed with exit code 2.
src/index.tsx(25,28): error TS2322: Type 'import("/home/runner/work/project/project/app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient' is not assignable to type 'import("/home/runner/work/project/project/app/.wasp/build/web-app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient'.
Types have separate declarations of a private property 'queryCache'.
Error: Process completed with exit code 2.
Vinny (@Wasp)
Vinny (@Wasp)3mo ago
Is the issue is resolved by upgrading to Wasp 0.16.5? curl -sSL https://get.wasp.sh/installer.sh | sh
hadanator
hadanator3mo ago
Ok I'm on 0.16.3. I'll try it out.
Vinny (@Wasp)
Vinny (@Wasp)3mo ago
Let me know if it works
hadanator
hadanator3mo ago
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.ai
kapa.ai
kapa.ai3mo ago
Let 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?
martinsos
martinsos3mo ago
@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.
hadanator
hadanator3mo ago
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:
- Your Wasp version does not match the app's requirements.
You are running Wasp 0.16.3.
This app requires Wasp ^0.16.5.
To install specific version of Wasp, do:
curl -sSL https://get.wasp.sh/installer.sh | sh -s -- -v x.y.z
where x.y.z is your desired version.
Check https://github.com/wasp-lang/wasp/releases for the list of valid versions.
- Your Wasp version does not match the app's requirements.
You are running Wasp 0.16.3.
This app requires Wasp ^0.16.5.
To install specific version of Wasp, do:
curl -sSL https://get.wasp.sh/installer.sh | sh -s -- -v x.y.z
where x.y.z is your desired version.
Check https://github.com/wasp-lang/wasp/releases for the list of valid versions.
I don't have anywhere else in my codebase with 0.16.3 referenced
MEE6
MEE63mo ago
Wohooo @hadanator, you just became a Waspeteer level 3!
hadanator
hadanator3mo ago
Oop just kidding, forgot to update the action yaml file to wasp 0.16.5
martinsos
martinsos3mo ago
Awesome!

Did you find this page helpful?