I am working on a React webapp using webpack, loosely alongside this tutorial.
Accidentally, I added the node_modules folder to my git. I then removed it again using
For global installation : npm install webpack-dev-server -g
For local installation npm install --save-dev webpack
When you refer webpack in package.json file, it tries to look it in location node_modules\.bin\
After local installation, file wbpack will get created in location: \node_modules\.bin\webpack
npm install webpack-dev-server -g -- windows OS
Better you use sudo in linux to avoid permission errors
sudo npm install webpack-dev-server -g
You could use sudo npm install webpack-dev-server --save to add it to package.json.
Sometimes you may require to run the below commands.
npm install webpack-cli --save or npm install webpack-cli -g
The script webpack-dev-server
is already installed inside ./node_modules directory.
You can either install it again globally by
sudo npm install -g webpack-dev-server
or run it like this
./node_modules/webpack-dev-server/bin/webpack-dev-server.js -d --config webpack.dev.config.js --content-base public/ --progress --colors
.
means look it in current directory.
Yarn
I had the problem when running: yarn start
It was fixed with running first: yarn install
I had similar problem with Yarn, none of above worked for me, so I simply removed ./node_modules
and run yarn install
and problem gone.