Fixing Webpack Error "Cannot find module WebpackOptions.json"

January 08, 2019

Using a tool with as many moving parts as webpack can come with its own headaches; mismatched versions of loaders, missing configurations etc. This error can happen often as a result of having webpack installed globally.

This is the full error message:

throw err;

Error: Cannot find module 'webpack/schemas/WebpackOptions.json'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)

Here's a quick fix:

npm uninstall -g webpack webpack-cli
npm install webpack webpack-cli --save-dev