Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

414
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda