I was trying to set up webpack-dev-server but I kept getting errors that required me to update webpack. I ran npm install --save-dev webpack@2.4.1
in my root directory to update Webpack, but I get this error when trying to run node_modules/.bin/webpack-dev-server
as well as node_modules/.bin/webpack
:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.resolve has an unknown property 'root'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
- configuration.resolve.extensions[0] should not be empty.
I know of the migration guide and I applied what I thought was needed to my project but I don't know what I'm missing. This is my webpack.config.js :
const path = require('path');
module.exports = {
context: __dirname + "/app",
entry: {
javascript: "./js/app.js",
html: "./index.html",
},
output: {
filename: "app.js",
path: __dirname + "/dist",
},
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
root: path.resolve(__dirname, './app/js'),
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, "app")
],
loaders: ["react-hot", "babel-loader"],
},
{
test: /\.html$/,
loader: "file?name=[name].[ext]",
}
],
},
}
My package.json looks like:
{
"name": "AAA",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --inline --history-api-fallback"
},
"devDependencies": {
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.16.0",
"eslint": "^3.13.1",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"file-loader": "^0.9.0",
"react-hot-loader": "^1.3.1",
"react-router": "^3.0.2",
"webpack": "^2.4.1",
"webpack-dev-server": "^1.16.2"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
}
How can I fix this error to launch the dev server and use webpack?
via feners
No comments:
Post a Comment