Reputation: 540
I cloned this Webpack Starter package through github using gitbash following a tutorial on pluralsight. I am trying to access webpack through Visual Studio Code's integrated terminal but i get the following error. I am new to this so kindly help me on this.
I am running a command
Raza Zaidi@RazaZaidi-PC MINGW64 ~/webpack-starter (master)
$ npm run dev
and then following error occurs
> [email protected] dev C:\Users\Raza Zaidi\webpack-starter
> webpack-dev-server --open --config webpack/webpack.config.dev.js
'webpack-dev-server' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack-dev-server --open --config webpack/webpack.config.dev.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev 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\Raza Zaidi\AppData\Roaming\npm-cache\_logs\2018-08-14T20_16_29_017Z-debug.log
Upvotes: 23
Views: 61853
Reputation: 1
if package.json file already exist with webpack, webpack-cli and dev server then simple use command npm install. Otherwise use commond npm install [email protected] or npm install --save-dev webpack@latest npm install --save-dev webpack-cli@latest npm install --save-dev webpack-dev-server@latest "webpack": "^4.30.0", "webpack-bundle-size-analyzer": "^3.0.0", "webpack-cli": "^3.3.1", "webpack-dev-server": "^3.3.1"
Upvotes: 0
Reputation: 41
first I've install webpack-dev-server in global
npm install -g webpack-dev-server
after installation I got this error..
Error: Cannot find module 'webpack'
this is version not matching problem, in my code I used these dependencies
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.2.2",
"babel-preset-es2015": "^6.24.1",
"webpack": "2.2.0-rc.3",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "2.1.0-beta.0",
"webpack-validator": "^2.3.0"
},
so change webpack-dev-server version in global
npm install -g [email protected]
in my case this was worked
Upvotes: 1
Reputation: 167
Check your node version, in my case switching to last node version helped.
Upvotes: 0
Reputation: 392
For me, instead of installing webpack-dev-server globally, I simply uninstalled and reinstalled the local package:
npm uninstall webpack-dev-server
npm install webpack-dev-server
Upvotes: 5
Reputation: 829
Webpack command should be present in location: node_modules\.bin\
In this case in package.json file we are referring to webpack-dev-server, but locally webpack-dev-server doesn't exist.
First run following command for global installation:
npm install -g webpack-dev-server
Second execute local installation command, which will create node_modules\.bin\webpack-dev-server
:
npm install webpack-dev-server --save-dev
Upvotes: 31
Reputation: 540
running
npm install -g webpack-dev-server
in cmd as an administrator solved my problem. I hope it helps others.
Upvotes: 12
Reputation: 350
Recent versions of Webpack & WDS need webpack-cli package, I recommend you to downloaded if your Webpack version is 4 or higher
Upvotes: 2