Reputation: 525
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;
Upvotes: 15
Views: 10105
Reputation: 575
in windows, run cmd in administrator mode, then
npm install -g webpack webpack-cli
Upvotes: 0
Reputation: 1560
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.
Upvotes: 15
Reputation: 508
Use the global version of webpack & webpack-cli for now. This affects local installations, as webpack and the cli are split and they can't resolve each other
Upvotes: 0
Reputation: 32061
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.
Upvotes: 2
Reputation: 71
I resolved this issue by simply adding webpack locally (yarn add --dev webpack). I had it installed globally but when I ran it in the console, gave me this error.
Hope it works for you!
Upvotes: 1
Reputation: 11
In that case you should need to run in your existing app
yarn install
or
npm install
It may fix your issue.
Upvotes: 1