我正试图在我的项目中实现next-i18next
。现在没有任何花哨的配置,基本上是将简单的示例放入当前的项目中。根据样本,一切似乎都很好。但是当我运行npm run dev
时,出现此错误
> 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)
这是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]
});
由于与the one from the sample几乎相同,所以看不到真正缺少的内容