W
Wasp•3mo ago
Johanfer

Node module doubling

I'm having problems during deploy, some about duplicates: Types have separate declarations of a private property 'queryCache' src/index.tsx(25,28): error TS2322: Type 'import("/root/Clever2/app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient' is not assignable to type 'import("/root/Clever2/app/.wasp/build/web-app/node_modules/@tanstack/query-core/build/lib/queryClient").QueryClient'.\n + " Types have separate declarations of a private property 'queryCache'.\n" Have any of you know how to fix it? Thanks!
6 Replies
kapa.ai
kapa.ai•3mo ago
Hi @Johanfer. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're seeing is a classic symptom of "node module doubling," where two separate installations of the same package (here, @tanstack/query-core) exist in different node_modules folders. This leads to TypeScript treating their types as incompatible, even though they're technically the same package, because they're loaded from different paths. This issue has been discussed in the Wasp community, especially after some restructuring changes. The root cause is often that dependencies (like React or @tanstack/query-core) are installed both in your main node_modules and inside generated folders like .wasp/build/web-app/node_modules. This can happen due to how Wasp manages SDK dependencies and how tools like Vite or NPM resolve modules. Potential solutions and workarounds: - Deduplication: Wasp maintainers have used the dedupe option in Vite to help with this, but it may not solve all cases and can introduce other build issues. The problem is not limited to React; it can affect any dependency, such as Prisma or Tanstack Query, if they're installed in multiple places. Temporarily, moving all dependencies that rely on a specific package (like prisma/client) into a single package.json (e.g., sdk/package.json) has helped avoid this problem in some cases, but it's not a universal fix yet Solve double installation issue in restructuring. - Manual Cleanup: As a workaround, deleting redundant node_modules folders (especially inside .wasp/build/web-app) and Vite's cache, then reinstalling dependencies, can sometimes resolve the issue. For example, running a script to remove the extra node_modules and restarting the app has been suggested as a temporary fix. - NPM Workspaces: Using NPM workspaces or similar monorepo tools can help ensure a single version of each dependency is used throughout the project, but this is not yet the default setup in Wasp. - Peer Dependencies: Listing shared dependencies as peerDependencies in the SDK was tried, but it did not resolve the issue in all cases. Summary:
This is a known issue in Wasp's current structure, especially after recent changes. There is no definitive, permanent fix yet, but cleaning up duplicate node_modules and ensuring dependencies are only installed once (ideally at the project root) is the best workaround for now. The Wasp team is aware and working on more robust solutions. If you continue to have trouble, please share your project structure and how dependencies are installed, as this can help pinpoint the specific cause in your setup. For more details, see the discussion here: Solve double installation issue in restructuring. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Johanfer, 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?
Johanfer
JohanferOP•3mo ago
I've already cleaned with wasp clean and npm dedupe but problem persists 😫
NEROX
NEROX•3mo ago
Did you tried rm -rf .wasp node_modules/ package-lock.json Sometimes it helps me when wasp clean doesn't solve it.
genyus
genyus•3mo ago
Just suggested the same in the mega-thread 😅
NEROX
NEROX•3mo ago
uh didn't saw, where?

Did you find this page helpful?