fix(gatsby): "Cannot find module 'babel-preset-gatsby'" error #30813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
yarn
, but it is possible ifbabel-preset-gatsby
doesn't get hoisted for some reason.