Reputation: 21
output: export
and i18n Conflict During BuildI am facing an issue with next export
and output: export
configuration in Next.js. Since next export
has been deprecated in favor of output: export
, I followed suggestions to update my next.config.js
file. However, I encountered multiple errors after making the changes.
When I run yarn export
, I get the following error:
Error: Specified "i18n" cannot be used with "output: export". See more info here: https://nextjs.org/docs/messages/export-no-i18n
I read online that next export
and output: export
are incompatible with i18n
locales, but I can't remove my locale configuration as it would cause several issues in my project. Removing the i18n
configuration leads to numerous other errors, which are difficult to manage without potentially regenerating all pages.
next.config.js
module.exports = {
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: [`@svgr/webpack`],
});
return config;
},
i18n: {
locales: ['en', 'de', 'ar'],
defaultLocale: 'en',
localeDetection: false,
},
images: {
unoptimized: true,
domains: ['your-domain.com'],
},
experimental: {
isrMemoryCacheSize: 0,
workerThreads: true,
cpus: Math.max(1, require('os').cpus().length / 2),
},
};
package.json Scripts
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"export": "next build && next export",
"static": "next build",
"serve": "npx serve out",
"type-check": "tsc",
"lint": "eslint --ignore-path .gitignore \"src/**/*.+(ts|js|tsx)\"",
"format": "prettier --ignore-path .gitignore \"src/**/*.+(ts|js|tsx)\" --write",
"postinstall": "husky install"
}
next export
has been removed in favor of output: export
in Next.js.output: export
in next.config.js
leads to the error: "i18n cannot be used with 'output: export'".i18n
breaks the existing functionality and would require regenerating all pages.output: 'export'
to next.config.js
as suggested by Next.js documentation.i18n
locales, but this led to various other errors.output: export
and i18n
together.Any help or guidance would be highly appreciated!
Upvotes: 2
Views: 86