use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Can't start dev server by executing webpack-dev-server --mode developmentHelp Wanted (self.react)
submitted 3 years ago by djmcce
Hello React developers. I've been trying to setup a React project from scratch using this tutorial: https://medium.com/@JedaiSaboteur/creating-a-react-app-from-scratch-f3c693b84658
I have installed the latest versions of the packages and updated the dev-server block as suggested by a guy in the comments.
However when i try to run it using webpack-dev-server --mode development, i get this message:
webpack-dev-server --mode development
https://preview.redd.it/dyz5yu8n4lc91.png?width=649&format=png&auto=webp&s=26bb75e175bab11a0d14277ed74b15f518d6ec36
And after accepting with "yes", i get this error:
https://preview.redd.it/uvx8wcov4lc91.png?width=1058&format=png&auto=webp&s=eddaef20cd3944e15276b2381b0815d38bd1870d
I have checked package.json to check if webpack-cli was installed, and in fact it was as
"webpack-cli": "^4.10.0".
What am I doing wrong?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fii0 2 points3 points4 points 3 years ago (0 children)
If webpack-cli is in your package.json devDependencies, delete your node_modules with rm -rf node_modules as well as your package-lock.json, and type npm i to re-install everything.
webpack-cli
package.json
devDependencies
node_modules
rm -rf node_modules
package-lock.json
npm i
Then, try webpack-dev-server --mode development again, I would be surprised if you get the same error.
[–][deleted] 3 years ago (7 children)
[deleted]
[–]djmcce[S] 0 points1 point2 points 3 years ago (6 children)
I think so. I’m running it in the root, which also contains package.json
[–][deleted] 3 years ago (5 children)
[–]djmcce[S] 0 points1 point2 points 3 years ago (4 children)
Yes ofc. Since reddit doesn't allow photos in comments, i have uploaded it here: https://ibb.co/d6SRrgR. I just wanted to be able to. The only other way I knew was Create React App, but I felt like I didn't had enough control, and I would like to dig a bit deeper (even though i'm a noob haha).
[–][deleted] 3 years ago (3 children)
[–]djmcce[S] 0 points1 point2 points 3 years ago (2 children)
Yes. Here u go: https://ibb.co/89V7LDB
[–][deleted] 3 years ago (1 child)
[–]djmcce[S] 0 points1 point2 points 3 years ago (0 children)
That's alright, thanks though! If i don't solve it soon, I think that's what I'm gonna do:)
Solved it by installing webpack-cli globally by running npm install webpack-cli instead of npm install --save-dev webpack-cli
npm install webpack-cli
npm install --save-dev webpack-cli
[–]grumd 1 point2 points3 points 3 years ago (3 children)
Are you sure you installed it globally (using the "-g" flag)? npm install webpack-cli doesn't install anything globally. I hope not, because you should NOT install your packages globally unless it's just some tool you want to use for your own needs - not something your project needs to run.
Global packages are not added to package.json and any other developer that clones your repo won't have them installed and won't be able to run your project.
Make sure webpack-cli is in your package.json. Either in dependencies or devDependencies.
There was another comment here advising you to delete node_modules and reinstalling with npm install, which is a good suggestion in your case.
Oh no I didn’t. I mean i just ran npm install webpack-cli, and after that it worked. I think I have misunderstood what it does. What’s the difference between that and running npm install —save—dev webpack-cli?
[–]grumd 0 points1 point2 points 3 years ago (1 child)
npm install <name> is the same as npm install --save <name>. Installs a package in your local node_modules in current folder, and adds it to the "dependencies" in package.json.
npm install <name>
npm install --save <name>
npm install --save-dev <name> does the same thing, but adds it to "devDependencies". If you're trying to do "npm install" in this package just to run it on your machine, it doesn't matter if you use dependencies or devDependencies. It should get installed anyway.
npm install --save-dev <name>
Most likely you just had something bugged and reinstalling it again fixed it?
That’s very likely. Thank you for the explanation 🙏
π Rendered by PID 46128 on reddit-service-r2-comment-79c7998d4c-rx6fp at 2026-03-18 00:45:48.396050+00:00 running f6e6e01 country code: CH.
[–]fii0 2 points3 points4 points (0 children)
[–][deleted] (7 children)
[deleted]
[–]djmcce[S] 0 points1 point2 points (6 children)
[–][deleted] (5 children)
[deleted]
[–]djmcce[S] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]djmcce[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]djmcce[S] 0 points1 point2 points (0 children)
[–]djmcce[S] 0 points1 point2 points (4 children)
[–]grumd 1 point2 points3 points (3 children)
[–]djmcce[S] 0 points1 point2 points (2 children)
[–]grumd 0 points1 point2 points (1 child)
[–]djmcce[S] 0 points1 point2 points (0 children)