gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.22k stars 10.33k forks source link

Gatsby v3 - SSR bundle failed - build issues, using Yarn v2 #30114

Closed ff4500 closed 3 years ago

ff4500 commented 3 years ago

Description

A new site from gatsby new doesn't work with Yarn.

I noticed this on migrating an older site from Gatsby v2 to v3 and wanted to test it from a clean slate. Sourced a new site from the automated build via cli and started it up with npm run develop just fine. Added yarn (v2), ran it and tried to start up the same minimal site with yarn clean && yarn develop. Webpack errors resulted. This is similar to the other tests that I've done with two other sites that use yarn instead of npm.

Steps to reproduce

gatsby new

cd my-gatsby-site && npm run develop

yarn set version berry

yarn

yarn clean && yarn develop

The result of the previous commands and files are in a minimal repo, here: https://github.com/ff4500/gatsby-v3-minimal

Expected result

Yarn should start the development server exactly as npm does.

Actual result

Yarn pooped out and threw some Generating development SSR bundle failed errors.

info Deleting .cache, public, /Users/ff4500/Desktop/my-gatsby-site/node_modules/.cache/babel-loader,
/Users/ff4500/Desktop/my-gatsby-site/node_modules/.cache/terser-webpack-plugin
info Successfully deleted directories

success open and validate gatsby-configs - 0.038s
success load plugins - 0.099s
success onPreInit - 0.027s
success initialize cache - 0.010s
success copy gatsby files - 0.166s
success onPreBootstrap - 0.032s
success createSchemaCustomization - 0.003s
success Checking for changed pages - 0.003s
success source and transform nodes - 0.280s
success building schema - 0.260s
info Total nodes: 18, SitePage nodes: 1 (use --verbose for breakdown)
success createPages - 0.002s
success Checking for changed pages - 0.001s
success createPagesStatefully - 0.052s
success update schema - 0.038s
success write out redirect data - 0.002s
success onPostBootstrap - 0.002s
info bootstrap finished - 4.380s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.118s
success write out requires - 0.007s
success run page queries - 0.031s - 3/3 97.88/s

 ERROR #98124  WEBPACK

Generating development SSR bundle failed

Can't resolve 'prop-types' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'prop-types' is installed. If you're trying to use a local file make sure that the path is
correct.

File: .cache/default-html.js:2:0

 ERROR #98124  WEBPACK

Generating development SSR bundle failed

Can't resolve 'lodash' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'lodash' is installed. If you're trying to use a local file make sure that the path is
correct.

File: .cache/develop-static-entry.js:3:0

not finished Building development bundle - 1.651s

Environment

  System:
    OS: macOS 11.2
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.11.0 - ~/.nodenv/shims/node
    Yarn: 2.4.1 - /usr/local/bin/yarn
    npm: 7.6.0 - ~/.nodenv/shims/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 88.0.4324.192
    Firefox: 86.0
    Safari: 14.0.3
  npmGlobalPackages:
    gatsby-cli: 3.0.0
circlingthesun commented 3 years ago

It should work if you install prop-types and lodash and any other missing packages.

ff4500 commented 3 years ago

I'm aware that will potentially work, however it's the difference in npm vs yarn here, as they should both be running off of the same set of modules. Since yarn v2 doesn't use the node_modules folder like npm, the dependencies of the packages aren't getting satisfied. It seems like in this case, gatsby isn't set to reference packages that it requires, thus webpack throwing the SSR errors. The packages are there, the references to them seem to be off.

For instance, let's say that I DO run yarn add prop-types and yarn add lodash. Cool. Yarn installs these and everything is peachy. Let's run yarn clean && yarn develop again. Here are the results:

info Deleting .cache, public, /Users/ff4500/Desktop/my-gatsby-site/node_modules/.cache/babel-loader,
/Users/ff4500/Desktop/my-gatsby-site/node_modules/.cache/terser-webpack-plugin
info Successfully deleted directories

success open and validate gatsby-configs - 0.044s
success load plugins - 0.097s
success onPreInit - 0.028s
success initialize cache - 0.012s
success copy gatsby files - 0.166s
success onPreBootstrap - 0.030s
success createSchemaCustomization - 0.003s
success Checking for changed pages - 0.003s
success source and transform nodes - 0.281s
success building schema - 0.274s
info Total nodes: 18, SitePage nodes: 1 (use --verbose for breakdown)
success createPages - 0.002s
success Checking for changed pages - 0.001s
success createPagesStatefully - 0.044s
success update schema - 0.032s
success write out redirect data - 0.002s
success onPostBootstrap - 0.002s
info bootstrap finished - 4.402s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.109s
success write out requires - 0.008s
success run page queries - 0.024s - 3/3 123.59/s
warn Attempted import error: 'navigate' is not exported from 'gatsby' (imported as 'navigate').
warn Attempted import error: 'Link' is not exported from 'gatsby' (imported as 'Link').
warn Attempted import error: 'Link' is not exported from 'gatsby' (imported as 'Link').

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '@mikaelkristiansson/domready' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that '@mikaelkristiansson/domready' is installed. If you're trying to use a local file make sure
 that the path is correct.

File: .cache/app.js:9:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'query-string' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'query-string' is installed. If you're trying to use a local file make sure that the path
is correct.

File: .cache/dev-404-page.js:11:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'mitt' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'mitt' is installed. If you're trying to use a local file make sure that the path is
correct.

File: .cache/emitter.js:4:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'shallow-compare' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'shallow-compare' is installed. If you're trying to use a local file make sure that the
path is correct.

File: .cache/ensure-resources.js:7:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'stack-trace' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay/components'

If you're trying to use a package make sure that 'stack-trace' is installed. If you're trying to use a local file make sure that the path is
 correct.

File: .cache/fast-refresh-overlay/components/runtime-errors.js:9:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'platform' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay/helpers'

If you're trying to use a package make sure that 'platform' is installed. If you're trying to use a local file make sure that the path is
correct.

File: .cache/fast-refresh-overlay/helpers/focus-trap.js:10:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'css.escape' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay/helpers'

If you're trying to use a package make sure that 'css.escape' is installed. If you're trying to use a local file make sure that the path is
correct.

File: .cache/fast-refresh-overlay/helpers/focus-trap.js:11:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'anser' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay'

If you're trying to use a package make sure that 'anser' is installed. If you're trying to use a local file make sure that the path is
correct.

File: .cache/fast-refresh-overlay/utils.js:4:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '@gatsbyjs/reach-router/lib/utils' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that '@gatsbyjs/reach-router/lib/utils' is installed. If you're trying to use a local file make
sure that the path is correct.

File: .cache/find-path.js:4:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'gatsby-link' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'gatsby-link' is installed. If you're trying to use a local file make sure that the path is
 correct.

File: .cache/gatsby-browser-entry.js:10:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'gatsby-react-router-scroll' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'gatsby-react-router-scroll' is installed. If you're trying to use a local file make sure
that the path is correct.

File: .cache/gatsby-browser-entry.js:11:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '@gatsbyjs/reach-router' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that '@gatsbyjs/reach-router' is installed. If you're trying to use a local file make sure that
the path is correct.

File: .cache/navigation.js:13:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '@gatsbyjs/reach-router/lib/history' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that '@gatsbyjs/reach-router/lib/history' is installed. If you're trying to use a local file
make sure that the path is correct.

File: .cache/navigation.js:14:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'gatsby-link' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'gatsby-link' is installed. If you're trying to use a local file make sure that the path is
 correct.

File: .cache/navigation.js:15:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'gatsby-legacy-polyfills' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'gatsby-legacy-polyfills' is installed. If you're trying to use a local file make sure that
 the path is correct.

File: .cache/polyfill-entry.js:4:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'event-source-polyfill' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'event-source-polyfill' is installed. If you're trying to use a local file make sure that
the path is correct.

File: .cache/polyfill-entry.js:7:2

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve '@gatsbyjs/reach-router' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that '@gatsbyjs/reach-router' is installed. If you're trying to use a local file make sure that
the path is correct.

File: .cache/root.js:10:0

 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'gatsby-react-router-scroll' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

If you're trying to use a package make sure that 'gatsby-react-router-scroll' is installed. If you're trying to use a local file make sure
that the path is correct.

File: .cache/root.js:11:0

 ERROR #98123  WEBPACK

Generating development JavaScript bundle failed

/Users/ff4500/Desktop/my-gatsby-site/src/pages/404.js
  0:0  error  Parsing error: Your application tried to access babel-preset-gatsby, but it isn't declared in your dependencies; this makes
the require call ambiguous and unsound.

Required package: babel-preset-gatsby (via "babel-preset-gatsby")
Required by: /Users/ff4500/Desktop/my-gatsby-site/

Require stack:
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/plugins.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/babel-loader-virtual-8b988818e2/0/cache/babel-loader-npm-8.2.2-b4e600c2c5-362bb71573
.zip/node_modules/babel-loader/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/babel-loader.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/loadLoa
der.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/LoaderR
unner.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModule.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModuleFactory.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/Compiler.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/webpack.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/utils/setupHooks.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/cjs.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/start-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/start-webpack-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/index.js
-
/Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/services.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/commands/develop-process.js
- /Users/ff4500/Desktop/my-gatsby-site/.cache/tmp-12040-BnXCYWgSmNes

/Users/ff4500/Desktop/my-gatsby-site/src/pages/index.js
  0:0  error  Parsing error: Your application tried to access babel-preset-gatsby, but it isn't declared in your dependencies; this makes
the require call ambiguous and unsound.

Required package: babel-preset-gatsby (via "babel-preset-gatsby")
Required by: /Users/ff4500/Desktop/my-gatsby-site/

Require stack:
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/plugins.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/babel-loader-virtual-8b988818e2/0/cache/babel-loader-npm-8.2.2-b4e600c2c5-362bb71573
.zip/node_modules/babel-loader/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/babel-loader.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/loadLoa
der.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/LoaderR
unner.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModule.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModuleFactory.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/Compiler.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/webpack.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/utils/setupHooks.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/cjs.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/start-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/start-webpack-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/index.js
-
/Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/services.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/commands/develop-process.js
- /Users/ff4500/Desktop/my-gatsby-site/.cache/tmp-12040-BnXCYWgSmNes

βœ– 2 problems (2 errors, 0 warnings)

failed Building development bundle - 8.946s
ERROR in ./.cache/app.js 9:0-52
Module not found: Error: Can't resolve '@mikaelkristiansson/domready' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

ERROR in ./.cache/dev-404-page.js 11:0-39
Module not found: Error: Can't resolve 'query-string' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/_this_is_virtual_fs_path_/$virtual/async-requires.js 11:11-13:5
 @ ./.cache/app.js 17:0-52 28:0-70 30:27-40 28:0-70

ERROR in ./.cache/emitter.js 4:0-24
Module not found: Error: Can't resolve 'mitt' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/app.js 12:0-32 29:20-27

ERROR in ./.cache/ensure-resources.js 7:0-45
Module not found: Error: Can't resolve 'shallow-compare' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/root.js 16:0-49 65:46-61
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/fast-refresh-overlay/components/runtime-errors.js 9:0-37
Module not found: Error: Can't resolve 'stack-trace' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay/components'
 @ ./.cache/fast-refresh-overlay/index.js 12:0-60 144:46-59
 @ ./.cache/root.js 17:0-56 212:42-60
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/fast-refresh-overlay/helpers/focus-trap.js 10:0-33
Module not found: Error: Can't resolve 'platform' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay/helpers'
 @ ./.cache/fast-refresh-overlay/components/overlay.js 11:0-45 73:17-25
 @ ./.cache/fast-refresh-overlay/components/build-error.js 6:0-75 21:42-49 28:38-44 59:46-61 70:40-44 92:39-45
 @ ./.cache/fast-refresh-overlay/index.js 11:0-54 132:46-56
 @ ./.cache/root.js 17:0-56 212:42-60
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/fast-refresh-overlay/helpers/focus-trap.js 11:0-35
Module not found: Error: Can't resolve 'css.escape' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay/helpers'
 @ ./.cache/fast-refresh-overlay/components/overlay.js 11:0-45 73:17-25
 @ ./.cache/fast-refresh-overlay/components/build-error.js 6:0-75 21:42-49 28:38-44 59:46-61 70:40-44 92:39-45
 @ ./.cache/fast-refresh-overlay/index.js 11:0-54 132:46-56
 @ ./.cache/root.js 17:0-56 212:42-60
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/fast-refresh-overlay/utils.js 4:0-26
Module not found: Error: Can't resolve 'anser' in '/Users/ff4500/Desktop/my-gatsby-site/.cache/fast-refresh-overlay'
 @ ./.cache/fast-refresh-overlay/components/build-error.js 8:0-55 18:16-29 61:13-25
 @ ./.cache/fast-refresh-overlay/index.js 11:0-54 132:46-56
 @ ./.cache/root.js 17:0-56 212:42-60
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/find-path.js 4:0-56
Module not found: Error: Can't resolve '@gatsbyjs/reach-router/lib/utils' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/loader.js 8:0-87 117:4-17 219:19-27 239:11-25 246:19-27 360:19-27 405:19-27 440:19-27 452:19-27
 @ ./.cache/app.js 14:0-51 31:0-9 33:19-31

ERROR in ./.cache/gatsby-browser-entry.js 10:0-112
Module not found: Error: Can't resolve 'gatsby-link' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/query-result-store.js 7:0-44 150:44-71
 @ ./.cache/root.js 15:0-72 38:38-52 119:51-65 219:38-54
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/gatsby-browser-entry.js 11:0-66
Module not found: Error: Can't resolve 'gatsby-react-router-scroll' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/query-result-store.js 7:0-44 150:44-71
 @ ./.cache/root.js 15:0-72 38:38-52 119:51-65 219:38-54
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/navigation.js 13:0-67
Module not found: Error: Can't resolve '@gatsbyjs/reach-router' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/app.js 22:0-54 130:4-18

ERROR in ./.cache/navigation.js 14:0-67
Module not found: Error: Can't resolve '@gatsbyjs/reach-router/lib/history' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/app.js 22:0-54 130:4-18

ERROR in ./.cache/navigation.js 15:0-40
Module not found: Error: Can't resolve 'gatsby-link' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/app.js 22:0-54 130:4-18

ERROR in ./.cache/polyfill-entry.js 4:0-33
Module not found: Error: Can't resolve 'gatsby-legacy-polyfills' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

ERROR in ./.cache/polyfill-entry.js 7:2-34
Module not found: Error: Can't resolve 'event-source-polyfill' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'

ERROR in ./.cache/root.js 10:0-71
Module not found: Error: Can't resolve '@gatsbyjs/reach-router' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in ./.cache/root.js 11:0-59
Module not found: Error: Can't resolve 'gatsby-react-router-scroll' in '/Users/ff4500/Desktop/my-gatsby-site/.cache'
 @ ./.cache/app.js 21:0-26 136:49-53

ERROR in
/Users/ff4500/Desktop/my-gatsby-site/src/pages/404.js
  0:0  error  Parsing error: Your application tried to access babel-preset-gatsby, but it isn't declared in your dependencies; this makes
the require call ambiguous and unsound.

Required package: babel-preset-gatsby (via "babel-preset-gatsby")
Required by: /Users/ff4500/Desktop/my-gatsby-site/

Require stack:
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/plugins.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/babel-loader-virtual-8b988818e2/0/cache/babel-loader-npm-8.2.2-b4e600c2c5-362bb71573
.zip/node_modules/babel-loader/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/babel-loader.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/loadLoa
der.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/LoaderR
unner.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModule.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModuleFactory.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/Compiler.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/webpack.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/utils/setupHooks.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/cjs.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/start-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/start-webpack-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/index.js
-
/Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/services.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/commands/develop-process.js
- /Users/ff4500/Desktop/my-gatsby-site/.cache/tmp-12040-BnXCYWgSmNes

/Users/ff4500/Desktop/my-gatsby-site/src/pages/index.js
  0:0  error  Parsing error: Your application tried to access babel-preset-gatsby, but it isn't declared in your dependencies; this makes
the require call ambiguous and unsound.

Required package: babel-preset-gatsby (via "babel-preset-gatsby")
Required by: /Users/ff4500/Desktop/my-gatsby-site/

Require stack:
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/plugins.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/config/fil
es/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/@babel-core-npm-7.13.8-03bdcc31d5-f3c61e635a.zip/node_modules/@babel/core/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/babel-loader-virtual-8b988818e2/0/cache/babel-loader-npm-8.2.2-b4e600c2c5-362bb71573
.zip/node_modules/babel-loader/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/babel-loader.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/loadLoa
der.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/cache/loader-runner-npm-4.2.0-427f0e7134-e8b103ae98.zip/node_modules/loader-runner/lib/LoaderR
unner.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModule.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/NormalModuleFactory.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/Compiler.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/webpack.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-virtual-3242c2c70b/0/cache/webpack-npm-5.24.4-27b87a0455-d7a9ab3401.zip/node
_modules/webpack/lib/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/utils/setupHooks.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/$$virtual/webpack-dev-middleware-virtual-25df4aceca/0/cache/webpack-dev-middleware-npm-4.1.0-b
d38e1cadc-bd161996f3.zip/node_modules/webpack-dev-middleware/dist/cjs.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/utils/start-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/start-webpack-server.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/services/index.js
-
/Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/services.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/state-machines/develop/index.js
- /Users/ff4500/Desktop/my-gatsby-site/.yarn/unplugged/gatsby-virtual-ba4f576b21/node_modules/gatsby/dist/commands/develop-process.js
- /Users/ff4500/Desktop/my-gatsby-site/.cache/tmp-12040-BnXCYWgSmNes

βœ– 2 problems (2 errors, 0 warnings)

webpack compiled with 19 errors

We get lots more unresolved dependencies and SSR errors. And this is a vanilla install, with only gatsby, react and react-dom set in the package dependencies.

ff4500 commented 3 years ago

Of note, this is specifically a yarn v2 issue with Gatsby, as editing the .yarnrc.yml file in the dir and adding nodeLinker: node-modules will revert the yarn behavior back to v1, and use the node_modules folder. In this case, yarn develop works as it should, linked dependencies and all.

(per https://next.yarnpkg.com/getting-started/migration#if-required-enable-the-node-modules-plugin)

circlingthesun commented 3 years ago

I haven't actually looked at how the .cache gets generated, but it looks like code from a bunch of modules ends up in there. These module's dependencies are listed in their package.json files, but the code is being imported from .cache which is inside your project. Yarn 2 is very anal about having everything you import in your project be listed in your project's package.json. I guess a solution could be for gatsby to automatically add all these dependencies to your package.json?

In the interim you'll probably have to run yarn add @mikaelkristiansson/domready query-string mitt shallow-compare ... like I did yesterday. It all works once you nail the missing dependencies.

jnlsn commented 3 years ago

In case anyone is curious, this is the full list of dependencies I had to install to get version 3 running in Yarn 2.

yarn add @mikaelkristiansson/domready query-string mitt shallow-compare lodash gatsby-react-router-scroll @gatsbyjs/reach-router event-source-polyfill gatsby-legacy-polyfills gatsby-link anser css.escape platform stack-trace

It does work, but I'm hoping for a cleaner, more official solution.

github-actions[bot] commented 3 years ago

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

matt-morris commented 3 years ago

Any movement?

Gatsby is listed on the Yarn 2 docs as one of the libraries with "native" pnp support.

Is there an official position on Yarn 2/Berry?

github-actions[bot] commented 3 years ago

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

Razunter commented 3 years ago

I was getting The 'compilation' argument must be an instance of Compilation error with Yarn 2, npm install worked ok.

circlingthesun commented 3 years ago

Disabling strict mode is also a fix, add this to your .yarnrc.yaml

pnpMode: 'loose'
pnpFallbackMode: 'all'