Invalid configuration object. webpack
Invalid configuration object. webpack
npm run dev gives me this error:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration has an unknown property 'modules'. These properties are valid:
object mode?, amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, module?, name?, node?, output?, optimization?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions?
For typos: please correct them.
For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
Loaders should be updated to allow passing options via loader options in module.rules.
Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
plugins: [
new webpack.LoaderOptionsPlugin(
// test: /.xxx$/, // may apply this only for some modules
options:
modules: …
)
]
webpack.config.js
const path = require("path");
const htmlWebpackPlugin = require("html-webpack-plugin");
module.exports = env =>
const no_dist = env && env.dist === "false";
return
//webpack configuration
entry: ["@babel/polyfill", "./src/js/index.js"],
output:
path: path.resolve(__dirname, "dist"),
filename: "js/bundle.js"
,
mode: "development",
devServer:
inline: false,
contentBase: "./dist"
,
plugins: [
new htmlWebpackPlugin(
filename: "index.html",
template: "./src/index.html"
)
],
modules:
rules: [
test: /.js$/,
exclude: /node_modules/,
use:
loader: "babel-loader"
]
;
;
package.json
"name": "espn_project",
"version": "1.0.0",
"description": " project ",
"main": "index.js",
"scripts":
"dev": "webpack --mode development --env.dist=false",
"dev:dist": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
,
"author": "Chris Kelly",
"license": "ISC",
"devDependencies":
"@babel/core": "^7.0.1",
"@babel/preset-env": "^7.0.0",
"babel-loader": "^8.0.2",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.18.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
,
"dependencies":
"@babel/polyfill": "^7.0.0"
.babelrc
"presets": ["/env"]
1 Answer
1
As the error message says:
configuration has an unknown property 'modules'. These properties are valid: object { mode?, amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, module? ...
It is telling you that you have a property called modules
that isn't valid. The correct property name is module
(without the "s").
modules
module
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.