Error:
Cannot find module 'webpack/schemas/WebpackOptions.json'
My webpack.config.js looks like this -
var config = {
entry: './main.js',
output: {
path: '/',
filename: 'index.js',
},
devServer: {
inline: true,
port: 8080
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
}
]
}
}
module.exports = config;
Sorry to revive this but I had a different solution..
I had used
npm install -g webpack-cli
npm install webpack
The issue seems to happen for me because the CLI is expecting webpack to be installed globally as well? To fix this I instead installed both CLI and webpack locally
npm uninstall -g webpack-cli
npm install webpack webpack-cli
In my package.json I just added:
"scripts": {
"build": "./node_modules/.bin/webpack-cli",
"watch": "./node_modules/.bin/webpack-cli --watch",
}
Then whenever I need to use webpack I just use npm run build
or npm run watch
.
And boom everything magically worked!
This is an issue with Webpack though I believe. I will be reporting it and I'll try to update this answer with it's progress.
UPDATE (2018/05/11): I have reported the issue to the Webpack team on a task I believe may be related. Follow/contribute here: https://github.com/webpack/webpack-cli/issues/299#issuecomment-388390143
UPDATE (2018/05/23): There is apparently a fix now and the issue should be resolved in the next version of webpack-cli. As of this writing though it seems to still not be resolved yet in the public release version of webpack-cli.
Here's what worked for me:
npm uninstall -g webpack
npm install webpack
Then create a script in your package.json:
"scripts": {
"build": "webpack",
},
Then run npm run build
instead of running webpack
directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With