@@ -563,3 +563,107 @@ when generating a .md or .mdx file to document things, always add a frontmatter
563
563
## reading github repositories
564
564
565
565
You can use gitchamber .com to read repos files . run ` curl https://gitchamber.com ` to see how the API works . Always use curl to fetch the responses of gitchamber .com
566
+
567
+
568
+ ## fixing duplicate pnpm dependencies
569
+
570
+ sometimes typescript will fail if there are 2 duplicate packages in the workspace node_modules . this can happen in pnpm if a package is usedin 2 different places (even if inside a node_module package , transitive dependency ) with a different set of versions for a peer dependency
571
+
572
+ for example if better - auth depends on zod peer dep and zod is in different versions in 2 dependency subtrees
573
+
574
+ to identify if a pnpm package is duplicated search for the string " packagename@" inside ` pnpm-lock.yaml ` , notice the space in the search string . Then if the result returns multiple instances with a different set of peer deps inside the round brackets it means that this package is being duplicated . Here is an example of a package getting duplicated :
575
+
576
+ ```
577
+
578
+ better - auth @1.3 .6 (react - dom @19.1 .1 (react @19.1 .1 ))(react @19.1 .1 )(zod @3.25 .76 ):
579
+ dependencies :
580
+ ' @better-auth/utils' : 0.2 .6
581
+ ' @better-fetch/fetch' : 1.1 .18
582
+ ' @noble/ciphers' : 0.6 .0
583
+ ' @noble/hashes' : 1.8 .0
584
+ ' @simplewebauthn/browser' : 13.1 .2
585
+ ' @simplewebauthn/server' : 13.1 .2
586
+ better - call : 1.0 .13
587
+ defu : 6.1 .4
588
+ jose : 5.10 .0
589
+ kysely : 0.28 .5
590
+ nanostores : 0.11 .4
591
+ zod : 3.25 .76
592
+ optionalDependencies :
593
+ react : 19.1 .1
594
+ react - dom : 19.1 .1 (react @19.1 .1 )
595
+
596
+ better - auth @1.3 .6 (react - dom @19.1 .1 (react @19.1 .1 ))(react @19.1 .1 )(zod @4.0 .17 ):
597
+ dependencies :
598
+ ' @better-auth/utils' : 0.2 .6
599
+ ' @better-fetch/fetch' : 1.1 .18
600
+ ' @noble/ciphers' : 0.6 .0
601
+ ' @noble/hashes' : 1.8 .0
602
+ ' @simplewebauthn/browser' : 13.1 .2
603
+ ' @simplewebauthn/server' : 13.1 .2
604
+ better - call : 1.0 .13
605
+ defu : 6.1 .4
606
+ jose : 5.10 .0
607
+ kysely : 0.28 .5
608
+ nanostores : 0.11 .4
609
+ zod : 4.0 .17
610
+ optionalDependencies :
611
+ react : 19.1 .1
612
+ react - dom : 19.1 .1 (react @19.1 .1 )
613
+
614
+ ```
615
+
616
+ As you can see better - auth is listed twice with different set of peer deps . In this case it ' s because of zod being in version 3 and 4 in two subtrees of our workspace dependencies.
617
+
618
+ below i will describe how to generally deduplicate a package , I will use zod as an example . It works with any dependency found in the previous step .
619
+
620
+ To deduplicate the package we have to make sure we only have 1 version of zod installed in your workspace . DO NOT use overrides for this . Instead fix the problem by manually updating the dependencies that are forcing the older version of zod in the dependency tree .
621
+
622
+ to do so we have first to run the command ` pnpm -r why [email protected] ` to see the reason the older zod version is installed .
In this case the result is something like this :
623
+
624
+ ```
625
+
626
+ website / Users / morse / Documents / GitHub / fumabase / website (PRIVATE )
627
+
628
+ dependencies :
629
+ @better - auth / stripe 1.2 .10
630
+ ├─┬ better - auth 1.3 .6
631
+ │ └── zod 3.25 .76 peer
632
+ └── zod 3.25 .76
633
+ db link :../ db
634
+ └─┬ docs - website link :../ docs - website
635
+ ├─┬ fumadocs - docgen 2.0 .1
636
+ │ └── zod 3.25 .76
637
+ ├─┬ fumadocs - openapi link :../ fumadocs / packages / openapi
638
+ │ └─┬ @modelcontextprotocol / sdk 1.17 .3
639
+ │ ├── zod 3.25 .76
640
+ │ └─┬ zod - to - json - schema 3.24 .6
641
+ │ └── zod 3.25 .76 peer
642
+ └─┬ searchapi link :../ searchapi
643
+ └─┬ agents 0.0 .109
644
+ ├─┬ @modelcontextprotocol / sdk 1.17 .3
645
+ │ ├── zod 3.25 .76
646
+ │ └─┬ zod - to - json - schema 3.24 .6
647
+ │ └── zod 3.25 .76 peer
648
+ └─┬ ai 4.3 .19
649
+ ├─┬ @ai - sdk / provider - utils 2.2 .8
650
+ │ └── zod 3.25 .76 peer
651
+ └─┬ @ai - sdk / react 1.2 .12
652
+ ├─┬ @ai - sdk / provider - utils 2.2 .8
653
+ │ └── zod 3.25 .76 peer
654
+ └─┬ @ai - sdk / ui - utils 1.2 .11
655
+ └─┬ @ai - sdk / provider - utils 2.2 .8
656
+ └── zod 3.25 .76 peer
657
+ ```
658
+
659
+ Here we can see zod 3 is installed because of @modelcontextprotocol / sdk , @better - auth / stripe and agents packages . To fix the problem we can run
660
+
661
+ ```
662
+ pnpm update - r -- latest @modelcontextprotocol / sdk @better - auth / stripe agents
663
+ ```
664
+
665
+ This way if these packages include the newer version of the dependency zod will be deduplicated automatically .
666
+
667
+ In this case we could have only updated only @better - auth / stripe to fix the issue too , that ' s becaues @better-auth/stripe is the one that has better-auth as a peer dep. But finding what is the exact problematic package is difficult so it is easier to just update all packages you notice that we depend on directly in our workspace package.json files.
668
+
669
+ IF after doing this we still have duplicate packages you will have to ask help to the user . You can try deleting the node_modules and restart the approach but it rarely helps .
0 commit comments