nextConfig issue while building or running the project
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000
Binaries:
Node: 14.19.0
npm: 6.14.16
Yarn: 1.22.18
pnpm: N/A
Relevant packages:
next: 12.2.4-canary.8
eslint-config-next: 11.0.1
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
next config file is throwing error while building and warning while development
warn - Invalid next.config.js options detected:
[
{
"instancePath": "",
"schemaPath": "#/additionalProperties",
"keyword": "additionalProperties",
"params": {
"additionalProperty": "webpack5"
},
"message": "must NOT have additional properties"
},
{
"instancePath": "",
"schemaPath": "#/additionalProperties",
"keyword": "additionalProperties",
"params": {
"additionalProperty": "target"
},
"message": "must NOT have additional properties"
},
{
"instancePath": "",
"schemaPath": "#/additionalProperties",
"keyword": "additionalProperties",
"params": {
"additionalProperty": "webpackDevMiddleware"
},
"message": "must NOT have additional properties"
},
{
"instancePath": "",
"schemaPath": "#/additionalProperties",
"keyword": "additionalProperties",
"params": {
"additionalProperty": "configOrigin"
},
"message": "must NOT have additional properties"
},
{
"instancePath": "/amp/canonicalBase",
"schemaPath": "#/properties/amp/properties/canonicalBase/minLength",
"keyword": "minLength",
"params": {
"limit": 1
},
"message": "must NOT have fewer than 1 characters"
},
{
"instancePath": "/assetPrefix",
"schemaPath": "#/properties/assetPrefix/minLength",
"keyword": "minLength",
"params": {
"limit": 1
},
"message": "must NOT have fewer than 1 characters"
},
{
"instancePath": "/experimental/outputFileTracingRoot",
"schemaPath": "#/properties/experimental/properties/outputFileTracingRoot/minLength",
"keyword": "minLength",
"params": {
"limit": 1
},
"message": "must NOT have fewer than 1 characters"
},
{
"instancePath": "/i18n",
"schemaPath": "#/properties/i18n/type",
"keyword": "type",
"params": {
"type": "object"
},
"message": "must be object"
}
]
See more info here: https://nextjs.org/docs/messages/invalid-next-config
Expected Behavior
the build should not fail and dev command should work without any warning
Link to reproduction
it’s a private repo
To Reproduce
this is how next config file looks like:
const shell = require('shelljs');
const withPlugins = require('next-compose-plugins');
const optimizedImages = require('next-optimized-images');
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
const RollbarSourcemapPlugin = require('rollbar-sourcemap-webpack-plugin');
const isDev = process.env.NODE_ENV !== 'production';
const packages = JSON.parse(
shell.exec('npx lerna list --all --json', {
silent: true,
}).stdout,
);
const packageNames = packages
.reduce((a, currentPackage) => [...a, currentPackage.name], [])
.filter(item => item.includes('@assets'));
const withTM = require('next-transpile-modules')(packageNames);
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
async redirects() {
return [
{
source: '/signup',
destination: '/',
permanent: false,
},
];
},
images: {
disableStaticImages: true,
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
productionBrowserSourceMaps: true,
generateBuildId: async () => {
if (process.env.NEXT_PUBLIC_COMMIT_HASH) {
return process.env.NEXT_PUBLIC_COMMIT_HASH;
}
// return null to use default next.js build id if there is no commit hash
return null;
},
assetPrefix: isDev ? 'http://localhost:3000' : '',
webpack: (config, { dev, buildId }) => {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf)$/,
type: 'asset/resource',
});
config.plugins.push(
new FilterWarningsPlugin({
exclude: /mini-css-extract-plugin[^]*Conflicting order between:/,
}),
);
// to upload source maps to rollbar, we follow this example as reference
// https://github.com/thredup/rollbar-sourcemap-webpack-plugin/blob/c7569ddf99fc01041f12a3d4b2998ea0f93a8dbe/examples/next-js/next.config.js
if (!dev) {
// Generate a common `id` to be used when initializing Rollbar & when uploading the sourcemaps.
// This could be any common value, as long as it is used in `_document.js` when initializing Rollbar.
const codeVersion = JSON.stringify(buildId);
config.plugins.push(
new RollbarSourcemapPlugin({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
version: codeVersion,
publicPath: `${process.env.FRONTEND_ENDPOINT}/_next/`,
}),
);
}
return config;
},
};
module.exports = withPlugins(
[[withTM], [optimizedImages, { optimizeImagesInDev: true }]],
nextConfig,
);
Issue Analytics
- State:
- Created a year ago
- Reactions:23
- Comments:29 (2 by maintainers)
Top Results From Across the Web
warning Invalid next.config.js when running project - nextJs
"The root value has an unexpected property, autoComplete, which is not in the list of allowed properties (amp, ..." I wrapped it into...
Read more >Setting a custom build directory - next.config.js
Now if you run next build Next.js will use build instead of the default .next folder. distDir should not leave your project directory....
Read more >Environment Variables in Next.js - Frontend Digest
When developing locally, Next.js will load environment variables from a file ... Create a file called next.config.js at the root of your project...
Read more >How to Build Scalable Architecture for your Next.js Project
It's recommended (but not required) to close your dev server when running a Next.js build. Most of the time there is no issue...
Read more >next-pwa - npm
Start using next-pwa in your project by running `npm i next-pwa`. ... during build, please consider upgrade to webpack5 in next.config.js .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This bug is also present in next@12.3
if you are using window you need to download some c++ binaries files