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.

Cannot find @reach/router in gatsby-link

See original GitHub issue

Description

Migrated to gatsby 3, now getting this issue

Error in "C:\projects\onlixe\blog-insiders\insiders-template-react\gatsby-node.js": Cannot find module '@reach/router'
Require stack:
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby-link\index.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\cache-dir\commonjs\gatsby-browser-entry.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\gatsby-node.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\resolve-module-exports.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\load-plugins\validate.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\load-plugins\load.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\load-plugins\index.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\services\initialize.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\services\index.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\state-machines\develop\services.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\state-machines\develop\index.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\commands\develop-process.js
- C:\projects\onlixe\blog-insiders\insiders-template-react\.cache\tmp-23300-an3qIDriMlhr



  Error: Cannot find module '@reach/router'
  Require stack:
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby-link\index.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\cache-dir\commonjs\gatsby-browser-entry.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\gatsby-node.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\resolve-module-exports.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\load-plugins\validate.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\load-plugins\load.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\bootstrap\load-plugins\index.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\services\initialize.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\services\index.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\state-machines\develop\services.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\state-machines\develop\index.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\node_modules\gatsby\dist\commands\develop-process.js
  - C:\projects\onlixe\blog-insiders\insiders-template-react\.cache\tmp-23300-an3qIDriMlhr

  - loader.js:794 Function.Module._resolveFilename
    internal/modules/cjs/loader.js:794:15

  - loader.js:687 Function.Module._load
    internal/modules/cjs/loader.js:687:27

  - loader.js:849 Module.require
    internal/modules/cjs/loader.js:849:19

  - v8-compile-cache.js:159 require
    [insiders-template-react]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - index.js:22 Object.<anonymous>
    [insiders-template-react]/[gatsby-link]/index.js:22:15

  - v8-compile-cache.js:192 Module._compile
    [insiders-template-react]/[v8-compile-cache]/v8-compile-cache.js:192:30

  - loader.js:973 Object.Module._extensions..js
    internal/modules/cjs/loader.js:973:10

  - loader.js:812 Module.load
    internal/modules/cjs/loader.js:812:32

  - loader.js:724 Function.Module._load
    internal/modules/cjs/loader.js:724:14

  - loader.js:849 Module.require
    internal/modules/cjs/loader.js:849:19

  - v8-compile-cache.js:159 require
    [insiders-template-react]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - gatsby-browser-entry.js:15 Object.<anonymous>
    [insiders-template-react]/[gatsby]/cache-dir/commonjs/gatsby-browser-entry.js:15:43

  - v8-compile-cache.js:192 Module._compile
    [insiders-template-react]/[v8-compile-cache]/v8-compile-cache.js:192:30

  - loader.js:973 Object.Module._extensions..js
    internal/modules/cjs/loader.js:973:10

  - loader.js:812 Module.load
    internal/modules/cjs/loader.js:812:32

  - loader.js:724 Function.Module._load
    internal/modules/cjs/loader.js:724:14


not finished load plugins - 0.999s

error Command failed with exit code 1.

Environment

System:
    OS: Windows 10 10.0.18363
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.9.1 - /c/Users/Artem Shteltser/AppData/Local/Programs/Python/Python39/python
  Browsers:
    Edge: Spartan (44.18362.449.0)
  npmPackages:
    gatsby: ^3.0.0 => 3.0.0
    gatsby-image: ^3.0.0 => 3.0.0
    gatsby-link: ^3.0.0 => 3.0.0
    gatsby-plugin-emotion: ^6.0.0 => 6.0.0
    gatsby-plugin-env-variables: ^2.0.0 => 2.0.0
    gatsby-plugin-eslint: ^3.0.0 => 3.0.0
    gatsby-plugin-google-fonts: ^1.0.1 => 1.0.1
    gatsby-plugin-manifest: ^3.0.0 => 3.0.0
    gatsby-plugin-module-resolver: ^1.0.3 => 1.0.3
    gatsby-plugin-offline: ^4.0.0 => 4.0.0
    gatsby-plugin-portal: ^1.0.7 => 1.0.7
    gatsby-plugin-postcss: ^4.0.0 => 4.0.0
    gatsby-plugin-react-helmet: ^4.0.0 => 4.0.0
    gatsby-plugin-sharp: ^3.0.0 => 3.0.0
    gatsby-plugin-sitemap: ^3.0.0 => 3.0.0
    gatsby-source-filesystem: ^3.0.0 => 3.0.0
    gatsby-source-graphql: ^3.0.0 => 3.0.0
    gatsby-transformer-sharp: ^3.0.0 => 3.0.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
ichsanindrawcommented, Apr 21, 2022

hey I’m still facing this issue, can someone help me? I did deleted node_modules, package-lock.json and .cache and try to re-install npm install but it’s not working

I followed the instruction from here

Install a starter gatsby new my-wordpress-gatsby-site https://github.com/gatsbyjs/gatsby-starter-wordpress-blog

Screen Shot 2022-04-21 at 22 06 12 Screen Shot 2022-04-21 at 22 06 46 Screen Shot 2022-04-21 at 22 06 53
3reactions
fshowaltercommented, Mar 5, 2021

Confirmed this fixes my local install, HOWEVER, if you import { useLocation } from "@reach/router"; in a component (say in an SEO component to set the og:url property) it will still complain Can't resolve '@reach/router' in '/path/to/your/component'. Changing your reference to import { useLocation } from "@gatsbyjs/reach-router"; will fix it, but typescript will complain about no type definitions for @gatsbyjs/reach-router can we fix that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't resolve 'react-dom' in '/path/node_modules/gatsby-react ...
Try re-adding gatsby-react-router-scroll . npm install gatsby-react-router-scroll. You might want to run a gatsby clean first.
Read more >
Routing | Gatsby
Routes can be created in three ways: By creating React components in src/pages; By using the File System Route API to programmatically create...
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 >
react-router-hash-link | Yarn - Package Manager
When you click on a link created with react-router-hash-link it will scroll to the element on the page with the id that matches...
Read more >
Module not found: Can't resolve 'react-router-dom' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'react-router-dom'", make sure to install the react-router-dom package by opening your terminal ...
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