I can't seem to figure out how to properly add experiments
to my webpack config.
Here is my current environment:
To set up, I started a new Next.js app using the command npx create-next-app blog
According to the information from the documentation, I need to add a resolutions property to the package.json as shown below:
"dependencies": {
"next": "10.0.6",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"resolutions": {
"webpack": "5.21.2"
}
In my next.config.js, I have added the following configuration:
const webpack = require("webpack");
console.log(webpack.version); // 5.21.2
module.exports = {
webpack: function (config, options) {
console.log(options.webpack.version); // 4.44.1
config.experiments = {};
return config;
},
};
When running yarn dev
, I encounter this error:
- configuration[0] has an unknown property 'experiments'.
The issue seems to be that the required version of webpack is 5.21.2
, but the version being used in the configuration settings is 4.44.1
.