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

259
Visualizações
Unable to find file path in getStaticProps function of internal page in Next Js

I am working on multi-language feature on Next JS app. Here is the folder structure of my project.

Folder Structure of the app

On the index page i.e. Home page, I am able to get the locales module using getStaticProps :

export function getStaticProps({ locale }) {
    return {
      props: {
        messages: require(`../locales/${locale}.json`),
      },
    };
}

But when I use this in /settings/locations/index/js it is showing error as follows: enter image description here

I have tried with messages: require('@/locales/${locale}.json') and messages: require('../../locales/${locale}.json') both way.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think you should try with-

 return {
    props: {
      messages: require(`../../../locales/${locale}.json`),
    },
 };

about 4 years ago · Juan Pablo Isaza 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