Skip to content
Advertisement

Cannot find module ‘webpack’ using webpack-dev-server

Trying to get familiar to chat apps using this tutorial.

Everything looks good, but when I try to run npm run watch according to the directions in the end, I get an error with npm, mentioning the error is not with npm.

This watch script was created to run the following script:

JavaScript

When I try to run this line using npx, I get the following error:

JavaScript

This is my webpack.config.js:

JavaScript

I have tried to install webpack and webpack-cli a couple of times, and it did not correct the error. Tried to delete node_modules and package-lock.json and then reinstall the modules, and nothing happened as well. Any suggestions?

Adding package.json:

JavaScript

Advertisement

Answer

You need to install webpack-dev-server instead of webpack-dev. Update your package.json then delete your node_modules and npm install everything anew.

Also, I am not sure it is a very good idea to use react and related components as devDependencies as they’re used in runtime, but it depends on your bundle build and configuration.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement