2

I am building a react app from scratch. Usually, I am running the npm create-react-app and it generates everything for you. I am following this tutorial https://www.youtube.com/watch?v=deyxI-6C2u4&ab_channel=TraversyMedia and it has the GitHub repository in the description. The problem is - when i run "npm start" it should run this command

webpack-dev-server --mode development --open --hot

which is written here in the package.json

"scripts": {
    "start": "webpack-dev-server --mode development --open --hot",
    "build": "./node_modules/.bin/webpack --mode production"
  },

The command works if I am running it manually, but with npm start, it gives the following error

PS D:\React&Webpack4 boilerplate> npm start

> [email protected] start D:\React&Webpack4 boilerplate
> webpack-dev-server --mode development --open --hot

'Webpack4' is not recognized as an internal or external command,
operable program, or batch file.
internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module 'D:\...\webpack-dev-server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `webpack-dev-server --mode development --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\***\AppData\Roaming\npm-cache\_logs\2020-09-30T18_11_15_755Z-debug.log
2
  • You are having path setting issues for webpack Commented Sep 30, 2020 at 18:25
  • i guess it's installed in the node modules Commented Oct 1, 2020 at 11:10

2 Answers 2

1

I run into the same issue above. You can try the following:

"scripts": {
    "start": "webpack-dev-server --open --hot",
    "build": "./node_modules/.bin/webpack --mode production"
  },
Sign up to request clarification or add additional context in comments.

Comments

0

install it globally and try to add webpack path to local variables.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.