Closed redabacha closed 1 year ago
You may want to read through https://github.com/remix-run/remix/issues/683
You may want to read through #683
yep good point. i've read through it all and it gives the impression that pnp is fully supported and working which doesn't seem to be the case yet given my example.
so i've found three solutions that all seem to work:
react
and react-dom
as dependencies of your root level package.json
pnpMode: loose
in your .yarnrc.yml
packageExtensions
in your .yarnrc.yml
(changing the package names appropriately to whatever runtime you're using),
packageExtensions:
"@remix-run/dev@*":
peerDependencies:
react: "*"
"react-dom": "*"
"@remix-run/express@*":
peerDependencies:
react: "*"
"react-dom": "*"
"@remix-run/node@*":
peerDependencies:
react: "*"
"react-dom": "*"
"@remix-run/serve@*":
peerDependencies:
react: "*"
"react-dom": "*"
with @remix-run/deno
for example:
packageExtensions:
'@remix-run/deno@*':
peerDependencies:
react: '*'
'react-dom': '*'
'@remix-run/dev@*':
peerDependencies:
react: '*'
'react-dom': '*'
to me it looks like the issue is caused by react-router-dom
having peer dependencies on both react
and react-dom
that is unable to be resolved by esbuild (with the yarn pnp plugin and also with native pnp in 0.15+) as it may not be aware of the main app package.json
, only the root level package.json
for whatever reason.
there's additionally some red herring warnings that come from remix, e.g:
The path "@remix-run/deno" is imported in server.ts but "@remix-run/deno" was not found in your node_modules. Did you forget to install it?
The path "@remix-run/react" is imported in app/entry.server.tsx but "@remix-run/react" was not found in your node_modules. Did you forget to install it?
this is because remix is using require.resolve
here without specifying the paths
field (or using module.createRequire
) so it ends up looking at the wrong package.json
(from @remix-run/dev
instead of the main app package.json
) for resolution.
@redabacha thanks for your various P/Rs to help out with Yarn PnP. My project is now working off of those forks to unblock us.
A question: does anyone have path alias imports working correctly? For example, this import import { Hello } from "~/components/Hello";
results in the following error:
[remix] The path "~/components/Hello" is imported in app/routes/hello-demo.tsx but "~/components/Hello" was not found in your node_modules. Did you forget to install it?
[remix] šæ Rebuilt in 528ms
[remix] Error: Qualified path resolution failed: we looked for the following paths, but none could be accessed.
[remix]
[remix] Source path: /Users/mattste/Developer/vreps/majestic-vreps/apps/dashboard-v2/app/components/Hello
[remix] Not found: /Users/mattste/Developer/vreps/majestic-vreps/apps/dashboard-v2/app/components/Hello
[remix] Not found: /Users/mattste/Developer/vreps/majestic-vreps/apps/dashboard-v2/app/components/Hello.js
[remix] Not found: /Users/mattste/Developer/vreps/majestic-vreps/apps/dashboard-v2/app/components/Hello.json
[remix] Not found: /Users/mattste/Developer/vreps/majestic-vreps/apps/dashboard-v2/app/components/Hello.node
[remix]
[remix] Require stack:
[remix] - /Users/mattste/Developer/vreps/majestic-vreps/apps/dashboard-v2/build/index.js
[remix] - /Users/mattste/Developer/vreps/majestic-vreps/.yarn/__virtual__/@remix-run-serve-virtual-67dad97eda/0/cache/@remix-run-serve-npm-1.7.2-3a5dc60724-376ea7af65.zip/node_modules/@remix-run/serve/dist/index.js
My package.json has this line as shown in the example.
"~": "link:./app"
Is this still an issue? Here v1.19.1 works fine (except for https://github.com/remix-run/remix/issues/6994) in a monorepo with yarn workspaces, using pnp.
Cannot reproduce on 1.19.2 nor nightly
. This was likely fixed in #4301 when we switched to esbuild
's native Yarn PnP handling.
Not sure if this should be a separate issue, but I'm running Remix as one of the apps inside a yarn monorepo with workspaces (no pnp).
I'm getting the following errors, about 20 of those:
warn could not resolve "modes/src/file"
ā You imported "modes/src/file" in app/routes/$slug.tsx,
ā but that package is not in your `node_modules`.
ā Did you forget to install it?
ā
I'm using the future.v2_dev
, and all of the deps from the monorepo are defined in package.json
inside the Remix app.
yarn 1.22.19, node v20.3.1, remix 1.19.3
@rista404 could you share what the modes/src/file
import looks like in your app/routes/$slug.tsx
?
@rista404 could you share what the
modes/src/file
import looks like in yourapp/routes/$slug.tsx
?
Most, if not all, imports are in the following format: import { Component } from 'modes/src/file'
. I'm migrating the code from a vite-ssr project where everything worked without any additional configuration or tools.
Thanks for the help!
@rista404 looks like modes/src/file
will be interpreted as a modes
dependency, so you'd need to configure path aliases to get this working as you intend. If you are having issues with that, feel free to open a separate issue.
@pcattori after upgrading to Remix v2, the warnings are gone. No code change from my side was needed.
What version of Remix are you using?
1.7.0
Steps to Reproduce
yarn dlx create-remix@latest
with the default options for everythingyarn build
in the workspaceyarn start
in the workspaceExpected Behavior
it should build and run as normal, like how it is for a non-monorepo setup
Actual Behavior
yarn build
will output the following warnings:doing some quick digging, the real errors are being suppressed here. adding a
console.log
to see the real errors, we can observe the following output:while the build technically succeeds, running
yarn start
will produce the following output:reproduction repo: https://github.com/redabacha/remix-yarn-pnp-monorepo-broken-repro