Cannot read property 'publicRuntimeConfig' of undefined

Viewed 1586

I'im trying to implement next-i18next in my project. No fancy config right now, it's basically taking the simple sample and putting it my project at the moment. Everything seems to be fine according to the sample. But when I run npm run dev, I have this error

> npm run dev

> next-i18n@0.0.1 dev /mnt/e/Projects/next-i18n
> node server.js

/mnt/e/Projects/next-i18n/i18n.js:2
const { localeSubpaths } = require('next/config').default().publicRuntimeConfig;
                                                           ^

TypeError: Cannot read property 'publicRuntimeConfig' of undefined
    at Object.<anonymous> (/mnt/e/Projects/next-i18n/i18n.js:2:60)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Module.require (internal/modules/cjs/loader.js:1080:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/mnt/e/Projects/next-i18n/server.js:5:21)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)

Here is the content of i18n.js

const NextI18Next = require('next-i18next').default;
const { localeSubpaths } = require('next/config').default().publicRuntimeConfig;

const localeSubpathVariations = {
  none: {},
  foreign: {
    en: 'en'
  },
  all: {
    fr: 'fr',
    en: 'en'
  }
};

module.exports = new NextI18Next({
  otherLanguages: ['en'],
  localeSubpaths: localeSubpathVariations[localeSubpaths]
});

Don't really see what's missing as it is almost the same as the one from the sample

0 Answers
Related