remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
29.73k stars 2.5k forks source link

unable to build and run in yarn workspaces pnp monorepo #4106

Closed redabacha closed 1 year ago

redabacha commented 2 years ago

What version of Remix are you using?

1.7.0

Steps to Reproduce

  1. create a basic yarn monorepo with pnp enabled
  2. create the remix starter app in a workspace using yarn dlx create-remix@latest with the default options for everything
  3. run yarn build in the workspace
  4. additionally try to run yarn start in the workspace

Expected 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:

The path "@remix-run/react" is imported in app/root.tsx but "@remix-run/react" was not found in your node_modules. Did you forget to install it?
The path "react/jsx-runtime" is imported in app/routes/index.tsx but "react/jsx-runtime" was not found in your node_modules. Did you forget to install it?
The path "@remix-run/node" is imported in app/entry.server.tsx but "@remix-run/node" was not found in your node_modules. Did you forget to install it?
The path "react-dom/server" is imported in app/entry.server.tsx but "react-dom/server" was not found in your node_modules. Did you forget to install it?

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:

Error: @remix-run/dev tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: react (via "react/jsx-runtime")
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)
The path "react/jsx-runtime" is imported in app/routes/index.tsx but "react/jsx-runtime" was not found in your node_modules. Did you forget to install it?
Error: @remix-run/dev tried to access @remix-run/react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @remix-run/react
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)
The path "@remix-run/react" is imported in app/root.tsx but "@remix-run/react" was not found in your node_modules. Did you forget to install it?
Error: @remix-run/dev tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: react (via "react/jsx-runtime")
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)
Error: @remix-run/dev tried to access @remix-run/node, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @remix-run/node
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)
The path "@remix-run/node" is imported in app/entry.server.tsx but "@remix-run/node" was not found in your node_modules. Did you forget to install it?
Error: @remix-run/dev tried to access @remix-run/react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @remix-run/react
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)
Error: @remix-run/dev tried to access react-dom, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: react-dom (via "react-dom/server")
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)
The path "react-dom/server" is imported in app/entry.server.tsx but "react-dom/server" was not found in your node_modules. Did you forget to install it?
Error: @remix-run/dev tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: react (via "react/jsx-runtime")
Required by: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#patch:@remix-run/dev@npm%3A1.7.0#./.yarn/patches/@remix-run-dev-npm-1.7.0-fe40e11b54.patch::version=1.7.0&hash=2d868d&locator=remix-yarn-pnp-monorepo-broken-repro%40workspace%3A. (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/)

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/commands.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/run.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-dev-virtual-bbd09feed6/0/cache/@remix-run-dev-patch-f7da19538b-3b067b8179.zip/node_modules/@remix-run/dev/dist/compiler/plugins/serverBareModulesPlugin.js:82:21
    at callback (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:930:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async handleRequest (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/unplugged/esbuild-npm-0.14.51-a22b50b89c/node_modules/esbuild/lib/main.js:710:30)

while the build technically succeeds, running yarn start will produce the following output:

/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639
      Error.captureStackTrace(firstError);
            ^

Error: react-router-dom tried to access react (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

Required package: react
Required by: react-router-dom@virtual:1aa7e1352cb23ad08d7bd7b2186b449bc35ee2f380ace5370abd3a51ac11d7c0a172bf5ad8ac02fb8c152fe5fecd50a67ae363ea21daf8d389772d998655971d#npm:6.3.0 (via /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/react-router-dom-virtual-6ac023fafa/0/cache/react-router-dom-npm-6.3.0-508f6547e5-77603a654f.zip/node_modules/react-router-dom/umd/)

Ancestor breaking the chain: @remix-run/dev@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#npm:1.7.0
Ancestor breaking the chain: @remix-run/node@npm:1.7.0

Require stack:
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/react-router-dom-virtual-6ac023fafa/0/cache/react-router-dom-npm-6.3.0-508f6547e5-77603a654f.zip/node_modules/react-router-dom/umd/react-router-dom.production.min.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/react-router-dom-virtual-6ac023fafa/0/cache/react-router-dom-npm-6.3.0-508f6547e5-77603a654f.zip/node_modules/react-router-dom/main.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-server-runtime-virtual-1aa7e1352c/0/cache/@remix-run-server-runtime-npm-1.7.0-14d746512c-2aceb0d367.zip/node_modules/@remix-run/server-runtime/dist/routeMatching.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-server-runtime-virtual-1aa7e1352c/0/cache/@remix-run-server-runtime-npm-1.7.0-14d746512c-2aceb0d367.zip/node_modules/@remix-run/server-runtime/dist/server.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-server-runtime-virtual-1aa7e1352c/0/cache/@remix-run-server-runtime-npm-1.7.0-14d746512c-2aceb0d367.zip/node_modules/@remix-run/server-runtime/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/cache/@remix-run-node-npm-1.7.0-ba7dd9cc1d-1fcb5c982a.zip/node_modules/@remix-run/node/dist/implementations.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/cache/@remix-run-node-npm-1.7.0-ba7dd9cc1d-1fcb5c982a.zip/node_modules/@remix-run/node/dist/sessions/fileStorage.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/cache/@remix-run-node-npm-1.7.0-ba7dd9cc1d-1fcb5c982a.zip/node_modules/@remix-run/node/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-express-virtual-801944238c/0/cache/@remix-run-express-npm-1.7.0-4df6de053a-0d68cb27ee.zip/node_modules/@remix-run/express/dist/globals.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/@remix-run-express-virtual-801944238c/0/cache/@remix-run-express-npm-1.7.0-4df6de053a-0d68cb27ee.zip/node_modules/@remix-run/express/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/cache/@remix-run-serve-npm-1.7.0-f05b3a4c20-223ddafcc4.zip/node_modules/@remix-run/serve/dist/index.js
- /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/cache/@remix-run-serve-npm-1.7.0-f05b3a4c20-223ddafcc4.zip/node_modules/@remix-run/serve/dist/cli.js
    at Function.require$$0.Module._resolveFilename (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20639:13)
    at Function.require$$0.Module._load (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20493:42)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/react-router-dom-virtual-6ac023fafa/0/cache/react-router-dom-npm-6.3.0-508f6547e5-77603a654f.zip/node_modules/react-router-dom/umd/react-router-dom.production.min.js:11:79
    at Object.<anonymous> (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.yarn/__virtual__/react-router-dom-virtual-6ac023fafa/0/cache/react-router-dom-npm-6.3.0-508f6547e5-77603a654f.zip/node_modules/react-router-dom/umd/react-router-dom.production.min.js:11:305)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.require$$0.Module._extensions..js (/home/reda/Documents/Projects/remix-yarn-pnp-monorepo-broken-repro/.pnp.cjs:20683:33)
    at Module.load (node:internal/modules/cjs/loader:981:32)

reproduction repo: https://github.com/redabacha/remix-yarn-pnp-monorepo-broken-repro

machour commented 2 years ago

You may want to read through https://github.com/remix-run/remix/issues/683

redabacha commented 2 years ago

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.

redabacha commented 2 years ago

so i've found three solutions that all seem to work:

  1. add react and react-dom as dependencies of your root level package.json
  2. enable pnpMode: loose in your .yarnrc.yml
  3. add these 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.

mattste commented 2 years ago

@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"
lensbart commented 1 year ago

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.

pcattori commented 1 year ago

Cannot reproduce on 1.19.2 nor nightly. This was likely fixed in #4301 when we switched to esbuild's native Yarn PnP handling.

rista404 commented 1 year ago

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

pcattori commented 1 year ago

@rista404 could you share what the modes/src/file import looks like in your app/routes/$slug.tsx?

rista404 commented 1 year ago

@rista404 could you share what the modes/src/file import looks like in your app/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!

pcattori commented 1 year ago

@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.

rista404 commented 1 year ago

@pcattori after upgrading to Remix v2, the warnings are gone. No code change from my side was needed.