remix icon indicating copy to clipboard operation
remix copied to clipboard

unable to build and run in yarn workspaces pnp monorepo

Open redabacha opened this issue 3 years ago • 4 comments
trafficstars

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

redabacha avatar Aug 30 '22 23:08 redabacha

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

machour avatar Aug 31 '22 06:08 machour

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 avatar Sep 01 '22 15:09 redabacha

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.

redabacha avatar Sep 07 '22 09:09 redabacha

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

mattste avatar Sep 30 '22 19:09 mattste

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.

lensbart avatar Aug 02 '23 09:08 lensbart

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

pcattori avatar Aug 17 '23 18:08 pcattori

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 avatar Aug 25 '23 11:08 rista404

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

pcattori avatar Aug 25 '23 15:08 pcattori

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

rista404 avatar Aug 25 '23 16:08 rista404

@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 avatar Sep 18 '23 19:09 pcattori

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

rista404 avatar Sep 26 '23 10:09 rista404