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

fix(gatsby): "Cannot find module 'babel-preset-gatsby'" error #30813

Merged

Conversation

Js-Brecht
Copy link
Contributor

@Js-Brecht Js-Brecht commented Apr 11, 2021

Description

Fixes the webpack error "Cannot find module 'babel-preset-gatsby'" when running in develop mode.

This is very likely an issue with pnpm, and so will probably be an issue with yarn2 as well.

When these babel presets/plugins are not resolved to an absolute path, babel attempts to resolve them relative to its current working directory. babel-preset-gatsby does not exist as a dependency of my project, so babel is unable to find it.

This change will resolve the preset based on the location of the eslintConfig() function instead.

Temporary workaround

Installing babel-preset-gatsby in the default site project fixes the issue, because then babel is able to resolve the package.

Related Issues

Related to (fixes?) #30110

  • I can't say for sure if the cause of that issue is the same, because it doesn't really look like any of them were using pnpm. It would be odd for the error to be generated with yarn, but it is possible if babel-preset-gatsby doesn't get hoisted for some reason.

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Apr 11, 2021
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for spotting this. This is a v3 migration issue. Not sure why we didn't see it internally though.

@vladar vladar added topic: webpack/babel Webpack or babel bot: merge on green Gatsbot will merge these PRs automatically when all tests passes and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Apr 12, 2021
@gatsbybot gatsbybot merged commit 9789823 into gatsbyjs:master Apr 12, 2021
moonmeister added a commit that referenced this pull request Apr 14, 2021
* master: (183 commits)
  chore(gatsby-plugin-image): Remove version note (#30758)
  docs: retire 'How to Create Pages' stub and Recipes landing page (#30842)
  chore(docs): Fix typo (#30858)
  docs: fix invalid mailto links in 3.3 release notes (#30862)
  docs: release notes for 3.3 (#30837)
  fix(gatsby-source-wordpress): invalidate less queries during previews (#30770)
  fix(gatsby-starter-wordpress-blog): Fix altText (#30832)
  feat(contentful): warn users when using restricted content type names (#30715)
  Refactor: using-contentful to use gatsby-plugin-image exclusively (#30717)
  chore(gatsby-plugin-styled-components): Remove breaking changes section (#30806)
  fix(gatsby): webpack warnings are no longer in object format by default (#30801)
  fix(gatsby): Decode base path in runtime (#30682)
  fix(gatsby): "Cannot find module 'babel-preset-gatsby'" error (#30813)
  handle plugin parentDir resolution in resolvePlugin() (#30812)
  Port using-gatsby-image site to image plugin (#28489)
  fix(gatsby-source-contentful): De-dupe type names (#30834)
  feat(gatsby): Add aggregation resolvers (#30789)
  fix(gatsby-core-utils): fetch-remote-file download failure when missing content-length header (#30810)
  fix(renovate): add breaking minor updates to major updates list (#30676)
  chore(docs): Update migration guide for plugins that support both v2 & v3 (#30825)
  ...
vladar pushed a commit that referenced this pull request Apr 19, 2021
vladar pushed a commit that referenced this pull request Apr 19, 2021
@vladar
Copy link
Contributor

vladar commented Apr 19, 2021

Published in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes topic: webpack/babel Webpack or babel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants