yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.41k stars 1.11k forks source link

[Bug?]: dependency error when using yarn berry #5732

Closed Ryong-E closed 1 year ago

Ryong-E commented 1 year ago

Self-service

Describe the bug

I'm using Gatsby. I'm trying to apply yarn berry with yarn set version berry -> yarn install -> yarn start I get the following message

As a workaround, you can either install the package directly or use the .yarnrc.yml file with the pnpMode: loose in your .yarnrc.yml file.

Are there any other solutions?

Module build failed (from ./.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/babel-loader.js):
Error: gatsby tried to access @babel/plugin-transform-react-jsx, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @babel/plugin-transform-react-jsx
Required by: gatsby@virtual:b52fa53de345840734aae13ce2112e264c9c70f255dbf4dbbe590b66a273e3a608cef5a98a6664d5f19abae28bc38af11947443e08b9765a7c73168a49cefe43#npm:5.12.4
(via /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/)

Require stack:
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/babel-loader-helpers.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/babel-loader.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/webpack.config.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/start-server.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/services/start-webpack-server.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/services/index.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/state-machines/develop/services.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/state-machines/develop/index.js
- /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/commands/develop-process.js
- /Users/handongryong/Documents/my-blog/.cache/tmp-10721-x2b4Th6OmSHi
    at Function.require$$0.Module._resolveFilename (/Users/handongryong/Documents/my-blog/.pnp.cjs:32870:13)
    at resolve (node:internal/modules/cjs/helpers:109:19)
    at forEach (/Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/src/utils/babel-loader-helpers.ts:171:33)
    at Array.forEach (<anonymous>)
    at prepareOptions (/Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/src/utils/babel-loader-helpers.ts:169:45)
    at Object.config (/Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/src/utils/babel-loader.ts:118:25)
    at Object.<anonymous> (/Users/handongryong/Documents/my-blog/.yarn/__virtual__/babel-loader-virtual-d0062b6743/0/cache/babel-loader-npm-8.3.0-a5239d7ed2-d48bcf9e03.
zip/node_modules/babel-loader/lib/index.js:130:42)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/handongryong/Documents/my-blog/.yarn/__virtual__/babel-loader-virtual-d0062b6743/0/cache/babel-loader-npm-8.3.0-a5239d7ed2-d48bcf9e03.
zip/node_modules/babel-loader/lib/index.js:3:103)
    at _next (/Users/handongryong/Documents/my-blog/.yarn/__virtual__/babel-loader-virtual-d0062b6743/0/cache/babel-loader-npm-8.3.0-a5239d7ed2-d48bcf9e03.zip/node_modu
les/babel-loader/lib/index.js:4:194)

  ModuleBuildError: Module build failed (from ./.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/babel-loader.js):
  Error: gatsby tried to access @babel/plugin-transform-react-jsx, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
  Required package: @babel/plugin-transform-react-jsx
  Required by: gatsby@virtual:b52fa53de345840734aae13ce2112e264c9c70f255dbf4dbbe590b66a273e3a608cef5a98a6664d5f19abae28bc38af11947443e08b9765a7c73168a49cefe43#npm:5.12.
  4 (via /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/)
  Require stack:
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/babel-loader-helpers.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/babel-loader.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/webpack.config.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/utils/start-server.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/services/start-webpack-server.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/services/index.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/state-machines/develop/services.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/state-machines/develop/index.js
  - /Users/handongryong/Documents/my-blog/.yarn/unplugged/gatsby-virtual-db6b693683/node_modules/gatsby/dist/commands/develop-process.js
  - /Users/handongryong/Documents/my-blog/.cache/tmp-10721-x2b4Th6OmSHi

To reproduce

"scripts": {
    "develop": "gatsby develop",
    "start": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "typecheck": "tsc --noEmit"
  },
  "dependencies": {
    "@chakra-ui/gatsby-plugin": "^3.1.1",
    "@chakra-ui/react": "^2.5.1",
    "@chakra-ui/theme-tools": "^2.0.17",
    "@emotion/react": "^11.10.6",
    "@emotion/styled": "^11.10.6",
    "@mdx-js/react": "^2.3.0",
    "framer-motion": "^10.0.1",
    "gatsby": "^5.7.0",
    "gatsby-plugin-advanced-sitemap": "^2.1.0",
    "gatsby-plugin-gtag": "^1.0.13",
    "gatsby-plugin-image": "^3.7.0",
    "gatsby-plugin-manifest": "^5.7.0",
    "gatsby-plugin-mdx": "^5.7.0",
    "gatsby-plugin-robots-txt": "^1.8.0",
    "gatsby-plugin-sharp": "^5.7.0",
    "gatsby-plugin-typegen": "^3.1.0",
    "gatsby-remark-images": "^7.8.0",
    "gatsby-source-filesystem": "^5.7.0",
    "gatsby-transformer-sharp": "^5.7.0",
    "prism-react-renderer": "^1.3.5",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "reading-time": "^1.5.0",
    "rehype-autolink-headings": "^6.1.1",
    "rehype-slug": "^5.1.0"
  },
  "devDependencies": {
    "@types/node": "^18.14.0",
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@typescript-eslint/parser": "^4.33.0",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-react": "^7.32.2",
    "gatsby-plugin-root-import": "^2.0.9",
    "prettier": "^2.8.4",
    "typescript": "^4.9.5"
  },
  "packageManager": "yarn@3.6.3"
}

it my pacakage.json

yarn set version berry -> yarn install - yarn start

Environment

System:
  Os: macOS 13.5.2
  CPU: M1 pro
Binaries:
  Node: 18.12
  Yarn: 3.6.3
  npm : 8.19.2

Additional context

No response

arcanis commented 1 year ago

This is a Gatsby bug - they call resolve without providing the resolution root directory, so the plugins are resolved as if they were a dependency of theirs instead of yours.

Ryong-E commented 1 year ago

@arcanis

This is a Gatsby bug - they call resolve without providing the resolution root directory, so the plugins are resolved as if they were a dependency of theirs instead of yours.

Ask them to put it in the gastby package, or Is the only way to put it in my package?