Reputation: 337
I am learning react and Webpack dev server is not starting and giving me this error
internal/modules/cjs/loader.js:573 throw err; ^ Error: Cannot find module 'webpack'
Scripts
"scripts": {
"start": "webpack-dev-server --config=config/webpack.dev.js",
"build": "NODE_ENV=production webpack --config=config/webpack.prod.js",
"compile": "webpack --config webpack.config.js"
},
Terminal output
npm start
[email protected] start C:\Users\iClick Digital\ Documents\ZerotoMastery\frontendprojects\react-shopping-ca rt webpack-dev-server --config=config/webpack.dev.js
internal/modules/cjs/loader.js:573 throw err; ^
Error: Cannot find module 'webpack'
at Function.Module._resolveFilename (internal/modules/ cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader. js:497:25)
at Module.require (internal/modules/cjs/loader.js:626: 17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (C:\Users\iClick Digital\Documen ts\ZerotoMastery\frontendprojects\react-shopping-cart\conf ig\webpack.dev.js:2:17)
at Module._compile (internal/modules/cjs/loader.js:678 :30)
at Object.Module._extensions..js (internal/modules/cjs /loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:1 2)
at Function.Module._load (internal/modules/cjs/loader. js:520:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: webpack-dev-ser ver --config=config/webpack.dev.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start scr ipt.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missi ng, did you mean to install?
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\iClick Digital\AppData\Roaming\npm-c ache_logs\2018-09-02T12_06_07_432Z-debug.log
Upvotes: 1
Views: 2320
Reputation: 8102
you need to install all dependencies from your package.json by running this command:
npm i
later you can run all of your scripts like this:
npm run start
I hope this would be helpful
Upvotes: 1