Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: incorrectly configured peer dependencies (remix-run/node, remix-run/express) #1707

Closed
akomm opened this issue Jan 29, 2022 · 7 comments
Assignees
Labels
bug Something isn't working pm:yarn3 Bugs related to Yarn 3

Comments

@akomm
Copy link

akomm commented Jan 29, 2022

What version of Remix are you using?

1.1.3

What version of Node are you using? Minimum supported version is 14.

14.15.0

Steps to Reproduce

$ mkdir test && cd test
$ yarn set version berry
$ npx create-remix@latest .
// choose: 
// (Y) remix app server 
// (Y) typescript 
// (N) npm install
$ yarn

Expected Behavior

Install of packages without peer dependency warnings

Actual Behavior

➤ YN0002: │ @remix-run/express@npm:1.1.3 [2ec58] doesn't provide react (p7c8ac), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/express@npm:1.1.3 [2ec58] doesn't provide react-dom (pea579), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/node@npm:1.1.3 doesn't provide react (p5c915), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/node@npm:1.1.3 doesn't provide react-dom (pfe431), requested by @remix-run/server-runtime

IDs might vary over time.

Reason & Solution to this issue:

  • @remix-run/node and @remix-run/express depend on @remix-run/server-runtime.
  • @remix-run/server-runtime depends on react and react-dom as PEER
  • Issue: @remix-run/node and @remix-run/express must either provide the PEER as dependency, or delegate the peer dependency further, adding react and react-dom as peer dependency. The later is probably the intended behavior.

NPM might not give the warning (did not test, but since the issue is there I assumed you missed it because using NPM), but yarn spots an issue correctly. Its a misconception that peer dependencies are implicitly delegated over aux libraries like in this example @remix-run/node and @remix-run/express.

The problem with this, from my point unresolvable warnings around peer dependencies, it makes it harder to spot when a real peer issue comes up I'm really responsible for. Having useless warnings all the time conditions to ignore and overlook issues.

@akomm akomm added the bug Something isn't working label Jan 29, 2022
@nicholaschiang
Copy link
Contributor

I'm also encountering this issue and can't run get remix working with yarn berry without node_modules enabled:

nchiang@eevee ~/repos/remixed $ yarn dev
/home/nchiang/repos/remixed/.pnp.cjs:15316
    throw firstError;
    ^

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

Required package: jsesc
Required by: @remix-run/dev@npm:1.2.1 (via /home/nchiang/repos/remixed/.yarn/cache/@remix-run-dev-npm-1.2.1-a861da14fd-4874eca194.zip/node_modules/@remix-run/dev/compiler/plugins/)

Require stack:
- /home/nchiang/repos/remixed/.yarn/cache/@remix-run-dev-npm-1.2.1-a861da14fd-4874eca194.zip/node_modules/@remix-run/dev/compiler/plugins/serverAssetsManifestPlugin.js
- /home/nchiang/repos/remixed/.yarn/cache/@remix-run-dev-npm-1.2.1-a861da14fd-4874eca194.zip/node_modules/@remix-run/dev/compiler.js
- /home/nchiang/repos/remixed/.yarn/cache/@remix-run-dev-npm-1.2.1-a861da14fd-4874eca194.zip/node_modules/@remix-run/dev/cli/commands.js
- /home/nchiang/repos/remixed/.yarn/cache/@remix-run-dev-npm-1.2.1-a861da14fd-4874eca194.zip/node_modules/@remix-run/dev/cli.js
    at Function.external_module_.Module._resolveFilename (/home/nchiang/repos/remixed/.pnp.cjs:15315:55)
    at Function.external_module_.Module._load (/home/nchiang/repos/remixed/.pnp.cjs:15114:48)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/nchiang/repos/remixed/.yarn/cache/@remix-run-dev-npm-1.2.1-a861da14fd-4874eca194.zip/node_modules/@remix-run/dev/compiler/plugins/serverAssetsManifestPlugin.js:15:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.external_module_.Module._load (/home/nchiang/repos/remixed/.pnp.cjs:15164:14)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

@nicholaschiang
Copy link
Contributor

In addition to the packages @akomm mentioned in the original issue, I've also got @remix-run/dev throwing a warning:

➤ YN0000: ┌ Resolution step
➤ YN0002: │ @remix-run/dev@npm:1.2.1 doesn't provide react (pa55b1), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/dev@npm:1.2.1 doesn't provide react-dom (pdd9c9), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/express@npm:1.2.1 [38ac2] doesn't provide react (p1bffa), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/express@npm:1.2.1 [38ac2] doesn't provide react-dom (pea079), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/node@npm:1.2.1 doesn't provide react (pf4bb7), requested by @remix-run/server-runtime
➤ YN0002: │ @remix-run/node@npm:1.2.1 doesn't provide react-dom (pe7d48), requested by @remix-run/server-runtime
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed

@nicholaschiang
Copy link
Contributor

And, after adding all the aforementioned packages to my .yarnrc.yml file's packageExtensions, I'm also getting:

➤ YN0000: ┌ Resolution step
➤ YN0002: │ @remix-run/serve@npm:1.2.1 doesn't provide react (p5a72c), requested by @remix-run/express
➤ YN0002: │ @remix-run/serve@npm:1.2.1 doesn't provide react-dom (pc94b8), requested by @remix-run/express
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed

The final temporary fix that seems to resolve dependencies without any warnings is this (in .yarnrc.yml):

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: '*'

@nicholaschiang
Copy link
Contributor

So it seems all of those ☝️ packages' peerDependencies need to specify both react and react-dom.

nicholaschiang added a commit to nicholaschiang/remixed that referenced this issue Feb 20, 2022
@akomm
Copy link
Author

akomm commented Feb 21, 2022

Thats type of issue the warning by yarn tries to prevent. It just by chance working usually, because you don't require the package directly. The moment its used by you or via tooling directly somwhere its a prob. Hence need to either provide the dependency or pass if further as peer in package.json

@MichaelDeBoey
Copy link
Member

This is fixed by #4801

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.12.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pm:yarn3 Bugs related to Yarn 3
Projects
None yet
Development

No branches or pull requests

4 participants