Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find i18n folder when deploying via @zeit/Now #462

Closed
tamer-mohamed opened this issue Aug 17, 2019 · 21 comments
Closed

Can't find i18n folder when deploying via @zeit/Now #462

tamer-mohamed opened this issue Aug 17, 2019 · 21 comments

Comments

@tamer-mohamed
Copy link

tamer-mohamed commented Aug 17, 2019

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	

Screenshot 2019-08-17 at 19 18 04

Screenshot 2019-08-17 at 19 18 39

@isaachinman
Copy link
Contributor

Duplicate of #274.

@DutchPrince
Copy link

I've got the same problem

@isaachinman
Copy link
Contributor

@DutchPrince I do not have knowledge about now the now platform abstracts filesystems. I would welcome any PRs. Alternatively, you can consume your localisation content via network requests with any number of i18next plugins.

@DutchPrince
Copy link

@DutchPrince I do not have knowledge about now the now platform abstracts filesystems. I would welcome any PRs. Alternatively, you can consume your localisation content via network requests with any number of i18next plugins.

Thanks for your response!

What does PRs mean?

@isaachinman
Copy link
Contributor

What does PRs mean?

Pull requests. This is open source software and relies upon contributions from the community.

@Chill-Studio
Copy link

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/

Capture d’écran 2020-07-07 à 16 25 30

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.

@isaachinman
Copy link
Contributor

@Chill-Studio This issue needs to be resolved by the Vercel team, and they're aware of it: vercel/next.js#13624

@Chill-Studio
Copy link

Wo that's a fast answer thank you !

Arg I can see there is not workaround :(

@isaachinman
Copy link
Contributor

At the moment, the best "workaround" is to use a different serverless platform.

@limebear
Copy link

Is there any other platforms recommend?

@isaachinman
Copy link
Contributor

@limebear The issue has been resolved. Vercel is probably your best option.

@anialamo
Copy link

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/

Capture d’écran 2020-07-07 à 16 25 30

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.

@Chill-Studio did you found how to resolve this error? Can you help me please?

@isaachinman
Copy link
Contributor

@anialamo Check this repo. It's deployed on Vercel here. Good luck!

@DutchPrince
Copy link

Thanks for this!

@samiulhsohan
Copy link

@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?

@musps
Copy link

musps commented May 5, 2021

@samiulhsohan You need add the path of your locale files

// next-i18next.config.jjs
const path = require('path')

module.exports = {
  i18n: {
    defaultLocale: "en",
    locales: ["en", "fr"],
    localePath: path.resolve('./public/locales')
  },
};

@samiulhsohan
Copy link

@samiulhsohan You need add the path of your locale files

// next-i18next.config.jjs
const path = require('path')

module.exports = {
  i18n: {
    defaultLocale: "en",
    locales: ["en", "fr"],
    localePath: path.resolve('./public/locales')
  },
};

@musps It worked! Thanks!

flolu added a commit to flolu/flolu.de that referenced this issue Jun 10, 2021
flolu added a commit to flolu/flolu.de that referenced this issue Jun 10, 2021
@LluisPitarch
Copy link

LluisPitarch commented Jul 30, 2021

I have fixed in my case with this config:

//next-18next.config.js

const path = require('path');

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'es'],
    localePath: path.resolve('./public/locales'),
    defaultNS: 'app',
    serializeConfig: false,
  },
};

developed on Vercel i still have problems on Netlify

@nibblesnbits
Copy link

@samiulhsohan You need add the path of your locale files

// next-i18next.config.jjs
const path = require('path')

module.exports = {
  i18n: {
    defaultLocale: "en",
    locales: ["en", "fr"],
    localePath: path.resolve('./public/locales')
  },
};

I think this issue is back in recent versions (I'm on 13.2.2). I get a warning:

warn  - Invalid next.config.js options detected: 
warn  -     The value at .i18n has an unexpected property, localePath, which is not in the list of allowed properties (defaultLocale, domains, localeDetection, locales).
warn  - See more info here: https://nextjs.org/docs/messages/invalid-next-config

And it still works locally, but not in Vercel.

@riccardolardi
Copy link

@samiulhsohan You need add the path of your locale files

// next-i18next.config.jjs
const path = require('path')

module.exports = {
  i18n: {
    defaultLocale: "en",
    locales: ["en", "fr"],
    localePath: path.resolve('./public/locales')
  },
};

I think this issue is back in recent versions (I'm on 13.2.2). I get a warning:

warn  - Invalid next.config.js options detected: 
warn  -     The value at .i18n has an unexpected property, localePath, which is not in the list of allowed properties (defaultLocale, domains, localeDetection, locales).
warn  - See more info here: https://nextjs.org/docs/messages/invalid-next-config

And it still works locally, but not in Vercel.

I think you need to move localePath into the exported module root scope:

module.exports = {
  i18n: {
    locales: ['de-CH', 'fr', 'en'],
    defaultLocale: 'de-CH',
    localeDetection: true,
  },
  localePath: path.resolve('./public/locales'),
  reloadOnPrerender: process.env.NODE_ENV === 'development',
}

Not sure where it's documented but it worked for me.

@adrai
Copy link
Member

adrai commented May 24, 2023

@samiulhsohan You need add the path of your locale files

// next-i18next.config.jjs
const path = require('path')

module.exports = {
  i18n: {
    defaultLocale: "en",
    locales: ["en", "fr"],
    localePath: path.resolve('./public/locales')
  },
};

I think this issue is back in recent versions (I'm on 13.2.2). I get a warning:

warn  - Invalid next.config.js options detected: 
warn  -     The value at .i18n has an unexpected property, localePath, which is not in the list of allowed properties (defaultLocale, domains, localeDetection, locales).
warn  - See more info here: https://nextjs.org/docs/messages/invalid-next-config

And it still works locally, but not in Vercel.

I think you need to move localePath into the exported module root scope:

module.exports = {
  i18n: {
    locales: ['de-CH', 'fr', 'en'],
    defaultLocale: 'de-CH',
    localeDetection: true,
  },
  localePath: path.resolve('./public/locales'),
  reloadOnPrerender: process.env.NODE_ENV === 'development',
}

Not sure where it's documented but it worked for me.

here: https://github.com/i18next/next-i18next#vercel-and-netlify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests