Hey guys, I have a mono-repo with 2 different reac...
# help
a
Hey guys, I have a mono-repo with 2 different react apps, and I’m using Lerna + Yarn. The thing is, apparently my dependencies are conflicting each other… One of my apps uses React 16 and the other React 17. The newer app, using 17, builds correctly, but on the browser I’m getting errors and the page not loading. Once I delete the other old-app, it works fine. So somehow my apps are conflicting each other, I thought YARN would handle different packages versions itselft. Anybody facing same config?
s
Heya @Adrián Mouly, since the workspace is probably hoisting the modules into the root node_modules, then the conflict is happening there. You can try
nohoist
for the conflicting packages. You can specify an array of packages, which you do not want hoisted back to the root node_modules, they will then stay local to the app, and hopefully that fixes your conflict.
Detailed blog by yarn here: https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
Copy code
"workspaces": {
    "packages": [
      "web",
      "api"
    ],
    "nohoist": [
      "**/react"
    ]
  }
a
Interesting.
Maybe to be safe, should I no-hoist the entire project?
s
It can be easier
a
The problem is I’m not sure which packages are conflicting.
Because the build works fine.
s
I think the install steps will take longer, but this should no hoist everything:
Copy code
"workspaces": {
    "packages": [
      "web",
      "api"
    ],
    "nohoist": [
      "**/*"
    ]
  }
a
Yeah maybe I can noHoist everything that is ‘frontend’ related.
But the “backend” still should.
s
Yeah, give it a try no hoisting everything, if that doesn't fix it there must be something else
a
Yeah good idea.
Thanks for your support!