Berry: [Bug] peer dependency on parent package

Created on 27 Jan 2020  Â·  3Comments  Â·  Source: yarnpkg/berry

  • [ ] I'd be willing to implement a fix

Describe the bug

It looks as though when a package has a peer dependency on the package importing it, it's not resolved. I'm not sure if this is intended behaviour or not, and if it is, how it should be fixed.

In my case specifically, from what I can tell from this error, @babel/core is importing @babel/plugin-proposal-optional-chaining which then imports @babel/core. Yarn is expecting that @babel/core would have a dependency on itself, but that seems quite unusual.

Here's the error:

A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't

Required package: @babel/core (via "@babel/core")
Required by: @babel/plugin-proposal-optional-chaining@virtual:d5212c5320ac25329eb932d0ce5d5137cbd6ef54db0e90ab02c4e0b4c46a2f593f69f5b9cb1f5a65a82fd68127d025020ffc23232a67e91a47d737e8d15c39aa#npm:7.8.3 (via /Users/brad/src/.yarn/$$virtual/@babel-plugin-proposal-optional-chaining-virtual-f6167190cd/0/cache/@babel-plugin-proposal-optional-chaining-npm-7.8.3-11636bc994-1.zip/node_modules/@babel/plugin-proposal-optional-chaining/lib/)

Require stack:
- /Users/brad/src/.yarn/$$virtual/@babel-plugin-proposal-optional-chaining-virtual-f6167190cd/0/cache/@babel-plugin-proposal-optional-chaining-npm-7.8.3-11636bc994-1.zip/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js
- /Users/brad/src/.yarn/cache/@babel-core-npm-7.6.2-3634f9afbc-1.zip/node_modules/@babel/core/lib/config/files/plugins.js
- /Users/brad/src/.yarn/cache/@babel-core-npm-7.6.2-3634f9afbc-1.zip/node_modules/@babel/core/lib/config/files/index.js
- /Users/brad/src/.yarn/cache/@babel-core-npm-7.6.2-3634f9afbc-1.zip/node_modules/@babel/core/lib/index.js
- /Users/brad/src/.yarn/$$virtual/babel-loader-virtual-1799e215c2/0/cache/babel-loader-npm-8.0.6-ccc68d8d38-1.zip/node_modules/babel-loader/lib/index.js
- /Users/brad/src/.yarn/unplugged/gatsby-virtual-e0506f1f37/node_modules/gatsby/dist/utils/babel-loader.js
- /Users/brad/src/.yarn/cache/loader-runner-npm-2.4.0-c414104c2f-1.zip/node_modules/loader-runner/lib/loadLoader.js
- /Users/brad/src/.yarn/cache/loader-runner-npm-2.4.0-c414104c2f-1.zip/node_modules/loader-runner/lib/LoaderRunner.js
- /Users/brad/src/.yarn/cache/webpack-npm-4.41.0-113743c712-1.zip/node_modules/webpack/lib/NormalModule.js
- /Users/brad/src/.yarn/cache/webpack-npm-4.41.0-113743c712-1.zip/node_modules/webpack/lib/NormalModuleFactory.js
- /Users/brad/src/.yarn/cache/webpack-npm-4.41.0-113743c712-1.zip/node_modules/webpack/lib/Compiler.js
- /Users/brad/src/.yarn/cache/webpack-npm-4.41.0-113743c712-1.zip/node_modules/webpack/lib/webpack.js
- /Users/brad/src/.yarn/unplugged/gatsby-virtual-e0506f1f37/node_modules/gatsby/dist/commands/develop.js
- /Users/brad/src/.yarn/unplugged/gatsby-cli-npm-2.7.54-aacabc3d83/node_modules/gatsby-cli/lib/create-cli.js
- /Users/brad/src/.yarn/unplugged/gatsby-cli-npm-2.7.54-aacabc3d83/node_modules/gatsby-cli/lib/index.js
- /Users/brad/src/.yarn/unplugged/gatsby-virtual-e0506f1f37/node_modules/gatsby/dist/bin/gatsby.js

Environment if relevant (please complete the following information):

  • OS: macOS
  • Node version v10.16.0
  • Yarn version 2.0.0-rc.27

Additional context

I haven't provided more detail as I suspect this might be an easy one to answer. If there's extra information that would be useful let me know and I'll try to provide.

bug

Most helpful comment

All 3 comments

@bradleyayers Interesting, Yarn v2 assumes all the packages have dependencies on themselves (each package can require itself). Looks like a bug somewhere in the v2 code

This might just be a confusing error message, I think the root of the problem is that gatsby-plugin-typescript (package.json) depends on @babel/plugin-proposal-optional-chaining but doesn't provide the required @babel/core dependency that is being expected.

It's reported correctly when running yarn, so I'll close this and you can re-open if you think there's another problem:

➤ YN0002: │ gatsby-plugin-typescript@npm:2.1.26 [c440d] doesn't provide @babel/core@^7.0.0-0 requested by @babel/plugin-proposal-nullish-coalescing-operator@npm:7.8.3
➤ YN0002: │ gatsby-plugin-typescript@npm:2.1.26 [c440d] doesn't provide @babel/core@^7.0.0-0 requested by @babel/plugin-proposal-numeric-separator@npm:7.8.3
➤ YN0002: │ gatsby-plugin-typescript@npm:2.1.26 [c440d] doesn't provide @babel/core@^7.0.0-0 requested by @babel/plugin-proposal-optional-chaining@npm:7.8.3
➤ YN0002: │ gatsby-plugin-typescript@npm:2.1.26 [c440d] doesn't provide @babel/core@^7.0.0-0 requested by @babel/preset-typescript@npm:7.8.3
➤ YN0002: │ gatsby-plugin-typescript@npm:2.1.26 [c440d] doesn't provide graphql@^14.1.1 requested by babel-plugin-remove-graphql-queries@npm:2.7.22
Was this page helpful?
0 / 5 - 0 ratings

Related issues

benwainwright picture benwainwright  Â·  3Comments

IanVS picture IanVS  Â·  4Comments

Mike-Dax picture Mike-Dax  Â·  3Comments

juanpicado picture juanpicado  Â·  4Comments

wojtekmaj picture wojtekmaj  Â·  3Comments