Hi there! First of: Nice work with the library!
I have an application on Next.js v8 with next-i18next v0.44 and the following i18n.js file:
const NextI18Next = require('next-i18next/dist/commonjs')
module.exports = new NextI18Next({
defaultLanguage: 'en',
otherLanguages: ['de'],
// see: https://github.com/isaachinman/next-i18next/issues/328
localePath: process.browser ? 'static/locales' : 'src/nextjs/static/locales',
})
I wanted to update to Next.js v9 (which went smoothly) and afterwards updated next-i18next to v0.46.
After doing that and trying to start up the server I got the following error:
> node ./src/nextjs/server.js
/src/nextjs/i18n.js:3
module.exports = new NextI18Next({
^
TypeError: NextI18Next is not a constructor
at Object.<anonymous> (src/nextjs/i18n.js:3:18)
0.46
Any idea what may be causing this behaviour?
Look at the updated example.
const NextI18Next = require('next-i18next').default.
Gotcha, thanks for the quick feedback!
NextJs has updated their internal Babel setup, so module resolution is indeed slightly different. There are probably improvements to be made here, but as long as we have to export to a CJS target, things will be slightly weird.
Most helpful comment
Look at the updated example.
const NextI18Next = require('next-i18next').default.