next-i18next: Can't find i18n folder when deploying via @zeit/Now
Describe the bug
Tried to deploy examples/simple
to now but failed to run.
Occurs in next-i18next version
V1.0.0
Steps to reproduce
- clone examples/simple
- deploy to now
- 502: BAD_GATEWAY
Expected behaviour
it should run successfully on now platform
Screenshots
ERROR Uncaught Exception {"errorType":"Error","errorMessage":"ENOENT: no such file or directory, scandir '/var/task/static/locales/en'","code":"ENOENT","stack":["Error: ENOENT: no such file or directory, scandir '/var/task/static/locales/en'"," at Object.readdirSync (fs.js:790:3)"," at getAllNamespaces (/var/task/page.js:14724:19)"," at _default (/var/task/page.js:14729:27)"," at new NextI18Next (/var/task/page.js:17983:46)"," at Object.k7Sn (/var/task/page.js:14791:18)"," at __webpack_require__ (/var/task/page.js:23:31)"," at Module.Y0NT (/var/task/page.js:9811:63)"," at __webpack_require__ (/var/task/page.js:23:31)"," at Module.f8ve (/var/task/page.js:11600:85)"," at __webpack_require__ (/var/task/page.js:23:31)"],"errno":-2,"syscall":"scandir","path":"/var/task/static/locales/en"}
END RequestId: ba58e4b2-1a15-46d6-9693-00b1206c6973
REPORT RequestId: ba58e4b2-1a15-46d6-9693-00b1206c6973


About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 21 (8 by maintainers)
Commits related to this issue
- fix: set i18n locale path https://github.com/isaachinman/next-i18next/issues/462#issuecomment-832793454 — committed to flolu/flolu.de by flolu 3 years ago
- fix: set i18n locale path https://github.com/isaachinman/next-i18next/issues/462#issuecomment-832793454 — committed to flolu/flolu.de by flolu 3 years ago
- Update README.md Change is inspired by a problem I encountered after deploying my app to vercel and getting server errors for being unable to resolve the file locations for my locales. Solution was p... — committed to LemonFace0309/next-i18next by LemonFace0309 3 years ago
@samiulhsohan You need add the path of your locale files
Duplicate of #274.
@anialamo Check this repo. It’s deployed on Vercel here. Good luck!
@Chill-Studio did you found how to resolve this error? Can you help me please?
Excuse me guys I probably have searched for every thread that is related to this but I can’t find a way to tell the server what is the path to the locales… I didn’t find anything helping me in the said duplicate #274.
I am also using vercel, did anyone manage to make it work with next-i18next ?
My locales are located in public/static/locales
But when I deploy I got this path as not found
/var/task/public/static/locales/en’
I noticed that once deployed the structure on vercel has no public/
I know that “/public/static/locales” is the default i18n path, so I tried to change it to /static/locales so it will fit the vercel structure.
So I set localePath to “static/locales”
Then is does not deploy anymore and I got this as a path not found…
****/vercel/7d248d1f/static/locales/en’
I tried also the backEnd config option without success…
I am out of idea. Help 😢 Thank you guys.
At the moment, the best “workaround” is to use a different serverless platform.
here: https://github.com/i18next/next-i18next#vercel-and-netlify
I think you need to move
localePath
into the exported module root scope:Not sure where it’s documented but it worked for me.
I think this issue is back in recent versions (I’m on 13.2.2). I get a warning:
And it still works locally, but not in Vercel.
@isaachinman I am experiencing the same issue but for dynamic routes like
pages/posts/[...slug.js]
. Any idea how can I solve it? Can you please also add an example for dynamic routing on the example repo?