question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: Module not found: Error: Can't resolve '@gatsbyjs/reach-router/lib/utils' in '/.cache'

See original GitHub issue

Preliminary Checks

Description

I’m getting issue running yarn dev:

ModuleNotFoundError: Module not found: Error: Can't resolve '@gatsbyjs/reach-router/lib/utils' in '/Users/user/projects/personal/project/.cache'

and running yarn build:

failed Building production JavaScript and CSS bundles - 63.753s

 ERROR #98124  WEBPACK

Generating JavaScript bundles failed

Can't resolve '@gatsbyjs/reach-router/lib/utils' in
'/Users/user/projects/personal/prject/.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:1:0


 ERROR #98124  WEBPACK

Generating JavaScript bundles failed

Can't resolve '@gatsbyjs/reach-router/lib/history' in
'/Users/user/projects/personal/project/.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:1:394


error Command failed with exit code 1.

before that I had to force install gatsby-scripts, gatsby-react-router-scroll, gatsby-link into package.json, I have @gatsbyjs/reach-router installed and new Head API refactored, but can’t run dev, due an error above

It is just not looking down the node_modules tree. Please fix.

crosslink to the disscussion: https://github.com/gatsbyjs/gatsby/discussions/35313

Reproduction Link

no repro

Steps to Reproduce

Just running plain project with “gatsby”: “4.22.0”

Expected Result

Should run yarn dev without errors

Actual Result

ModuleNotFoundError: Module not found: Error: Can’t resolve ‘@gatsbyjs/reach-router/lib/utils’ in ‘/.cache’

Environment

System:
    OS: macOS 12.5.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 105.0.5195.102
    Firefox: 102.0.1
    Safari: 15.6.1
  npmPackages:
    gatsby: 4.22.0 => 4.22.0
    gatsby-link: 4.22.0 => 4.22.0
    gatsby-plugin-catch-links: 4.22.0 => 4.22.0
    gatsby-plugin-google-fonts: 1.0.1 => 1.0.1
    gatsby-plugin-minify-classnames: 4.1.3 => 4.1.3
    gatsby-plugin-root-import: 2.0.8 => 2.0.8
    gatsby-plugin-typescript: 4.22.0 => 4.22.0
    gatsby-react-router-scroll: 5.22.0 => 5.22.0
    gatsby-script: 1.7.0 => 1.7.0

Config Flags

no

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
barbalexcommented, Oct 2, 2022

Same here once again with 4.24

1reaction
aaron5670commented, Oct 7, 2022

Same problem here when we upgrade from React 17.0.2 to 18.2. We are on Gatsby 4.22.1.

Any solution to this? Since there are several open issues on Github with the same problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

problems launching gatsby develop #35313 - GitHub
Terminal says: Module not found: Error: Can't resolve '@gatsbyjs/reach-router/lib/utils' in '/Users/[myusername]/[foldername]/[gatsybyinstallation]/.cache' ...
Read more >
Gatsbyjs reach-router import error breaking site - Stack Overflow
js Attempted import error: 'BaseContext' is not exported from '@gatsbyjs/reach-router' (imported as 'BaseContext'). I can't seem to find a fix, ...
Read more >
Troubleshooting Common Errors - Gatsby
This error may be a top level Cannot resolve module 'fs' or part of a webpack error like Can't resolve 'fs' . fs...
Read more >
Migrating from GatsbyJS 2.16.2 to 3.9.0 - BobbyDreamer
Basically the intention was not to migrate but to add following features to the existing site and while executing Gatsby CLI commands saw...
Read more >
@gatsbyjs/reach-router - npm
Gatsby's fork to modernize reach-router. Latest version: 2.0.0, last published: a month ago. Start using @gatsbyjs/reach-router in your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found