Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

412
Views
Gatsbyjs reach-router import error breaking site

I was working on my Gatsby project and tried adding the React Cookie Consent package. After installing it and trying to implement it, my site broke down, proving me with this error:

   warn ./.cache/root.js
    Attempted import error: 'BaseContext' is not exported from '@gatsbyjs/reach-router' (imported as 'BaseContext').

I can't seem to find a fix, nor do I know why it is happening. Localhost is throwing me this error:

_gatsbyjs_reach_router__WEBPACK_IMPORTED_MODULE_2__.BaseContext is undefined

Any help is welcome! Thank you :)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Upon trying deleting the cache folder by running:

gatsby clean

If the issue persist, try bypassing the SSR limitation by adding the following to your gatsby-node.js:

exports.onCreateWebpackConfig = ({actions, loaders, stage}) => {
    if (stage === "build-html") {
        actions.setWebpackConfig({
            module: {
                rules: [
                    {
                        test: /react-cookie-consent/,
                        use: loaders.null(),
                    },
                ],
            }
        })
    }
};

Or using a dynamic import:

useEffect(() => {
  (async () => {
    const { getCookieConsentValue, Cookies } = await import('react-cookie-consent')

    getCookieConsentValue('test')
    Cookies.get()
  })()
}, [])

You can check for further approaches at: https://github.com/Mastermindzh/react-cookie-consent/issues/136

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!