Multiple major react versions in a pnpm monorepo?
Answered
Southern rough shrimp posted this in #help-forum

Southern rough shrimpOP
I'd love to have one app using react19, and the other using react18. However when I try to build either of them, there's a clash of versions and my IDE doesn't like it. See screenshots
repro: https://github.com/pippinmole/pnpm-monorepo-major-reactversions/ @Rafael Almeida
repro: https://github.com/pippinmole/pnpm-monorepo-major-reactversions/ @Rafael Almeida

Answered by Rafael Almeida
this is what I get trying to build it:
I am not sure this is related to TS or pnpm 🤔
> plasmo build --target=chrome-mv3
🟣 Plasmo v0.89.4
🔴 The Browser Extension Framework
🔵 INFO | Prepare to bundle the extension...
🔵 INFO | Building for target: chrome-mv3
🔵 INFO | Loaded environment variables from: []
(node:87004) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Segmentation fault (core dumped)
ELIFECYCLE Command failed with exit code 139.
I am not sure this is related to TS or pnpm 🤔
12 Replies

Southern rough shrimpOP
You can see that if I delete the
web
application from apps/web
, and run pnpm install
again, then the error is gone

I think TS is is looking at the wrong definitions because of how pnpm handles the folders in a monorepo. try directly setting the react types path on
tsconfig.compilerOptions.paths
:"react": ["./node_modules/@types/react"],
this is what I have on tsconfig and it seems to work:
{
"extends": "plasmo/templates/tsconfig.base",
"exclude": [
"node_modules"
],
"include": [
".plasmo/index.d.ts",
"./**/*.ts",
"./**/*.tsx"
],
"compilerOptions": {
"paths": {
"react": ["./node_modules/@types/react"],
"@/*": ["./src/*"]
},
"baseUrl": "."
}
}

@Rafael Almeida this is what I have on tsconfig and it seems to work:
json
{
"extends": "plasmo/templates/tsconfig.base",
"exclude": [
"node_modules"
],
"include": [
".plasmo/index.d.ts",
"./**/*.ts",
"./**/*.tsx"
],
"compilerOptions": {
"paths": {
"react": ["./node_modules/@types/react"],
"@/*": ["./src/*"]
},
"baseUrl": "."
}
}

Southern rough shrimpOP
Just to clarify, was there typescript errors before you added that line in
Also I remember adding this and it didn’t seem to work
I even restarted the typescript server

yeah I saw some errors because of forwardRef on the Input component, I restarted the ts server after adding the line

@Rafael Almeida yeah I saw some errors because of forwardRef on the Input component, I restarted the ts server after adding the line

Southern rough shrimpOP
Interesting, that did solve the IDE issues
But also, try running
turbo run build --filter=chromeextension
Or even
turbo run build

@Southern rough shrimp But also, try running turbo run build --filter=chromeextension

this is what I get trying to build it:
I am not sure this is related to TS or pnpm 🤔
> plasmo build --target=chrome-mv3
🟣 Plasmo v0.89.4
🔴 The Browser Extension Framework
🔵 INFO | Prepare to bundle the extension...
🔵 INFO | Building for target: chrome-mv3
🔵 INFO | Loaded environment variables from: []
(node:87004) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Segmentation fault (core dumped)
ELIFECYCLE Command failed with exit code 139.
I am not sure this is related to TS or pnpm 🤔
Answer

Southern rough shrimpOP
Closing as the issue has magically disappeared.