(Error: ENOENT: no such file or directory) (fixed)

i deployed my application here i am using a library for translations i need to specify a path to the folder on my localhost it works when i moved to vercel it stopped working even the files are here in source

)
i18next
    .use(Backend)
    .use(i18nextMiddleware.LanguageDetector)
    .init({
        lng: 'en', 
        fallbackLng: 'en',
        backend: {
            loadPath: path.join(process.cwd(), 'src/server/app/locales/{{lng}}.json'),
        },
        interpolation: {
            escapeValue: false, 
        },
    }, (err, t) => {
        if (err) {
            console.error('Error initializing i18next:', err);
        } else {
            console.log('i18next initialized successfully');
        }
    });;

i use this please help me

Erro ao inicializar o i18next: [
  [Error: ENOENT: no such file or directory, open '/var/task/src/server/app/locales/en.json'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/var/task/src/server/app/locales/en.json'
  }
]

i can fixed this using the includeFiles in vercel.json

Iā€™m glad you got it working. Thanks for coming back to share how you fixed it!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.