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

255
Views
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 answers
Answer question

0

I think you should try with-

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

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