Error: Cannot find module - webpack-dev-server
Montrail opened this issue · comments
I enter npm start into cli and this is what happens.
ERROR MESSAGE:
PS C:\Users\Montrail.Cooper\Projects\ReduxSimpleStarter> npm start
redux-simple-starter@1.0.0 start C:\Users\Montrail.Cooper\Projects\ReduxSimpleStarter
node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js
module.js:491
throw err;
^
Error: Cannot find module 'C:\Users\Montrail.Cooper\Projects\ReduxSimpleStarter\node_modules\webpack-dev-server\bin\webpack-dev-server.js'
WEBPACK CONFIG:
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-1']
}
}]
},
resolve: {
extensions: ['.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './',
open: true,
prot: 3030
}
};
PACKAGE.JSON:
{
"name": "redux-simple-starter",
"version": "1.0.0",
"description": "Simple starter package for Redux with React and Babel support",
"main": "index.js",
"repository": "git@github.com:StephenGrider/ReduxSimpleStarter.git",
"scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
"test:watch": "npm run test -- --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"chai": "^3.5.0",
"chai-jquery": "^2.0.0",
"jquery": "^2.2.1",
"jsdom": "^8.1.0",
"mocha": "^2.4.5",
"react-addons-test-utils": "^0.14.7",
"webpack": "^2.3.3",
"webpack-dev-server": "^2.4.2"
},
"dependencies": {
"babel-preset-stage-1": "^6.1.18",
"lodash": "^3.10.1",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "4.3.0",
"react-router": "^2.0.1",
"redux": "^3.0.4"
}
}
This may help you - paste this into package.json > then run 'npm install'.
{
"name": "redux-simple-starter",
"version": "1.0.0",
"description": "Simple starter package for Redux with React and Babel support",
"main": "index.js",
"repository": "git@github.com:StephenGrider/ReduxSimpleStarter.git",
"scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
"test:watch": "npm run test -- --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@segment/to-iso-string": "^1.0.1",
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-preset-stage-1": "^6.24.1",
"babel-core": "^6.26.0",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"chai": "^3.5.0",
"chai-jquery": "^2.0.0",
"jquery": "^2.2.1",
"jsdom": "^8.1.0",
"minimatch": "^3.0.4",
"mocha": "^2.4.5",
"pug": "^2.0.0-rc.4",
"react-addons-test-utils": "^0.14.7",
"webpack": "^1.15.0",
"webpack-dev-server": "^1.16.5"
},
"dependencies": {
"lodash": "^3.10.1",
"react": "^0.14.9",
"react-dom": "^0.14.9",
"react-redux": "^4.4.8",
"react-router": "^2.8.1",
"redux": "^3.7.2"
}
}
@Montrail Before you ran npm start
, did you run npm isntall
to install the required dependencies?
Hi Guys - If you're running into this issue try running npm install -g webpack-dev-server@1.16.5
, then run webpack-dev-server
It seems that this is caused by versioning in some of SG's (excellent) tutorials.
I installed some different presets:
npm install --save-dev babel-preset-es2015 babel-preset-react
then in /webpack.config.js added:
{ test: /\.jsx?$/, exclude: /(node_modules)/, loader: 'babel-loader', query: { presets: ['es2015', 'react'] },
That seemed to get my build going.
Same issue @StephenGrider (node: 8.9.0 | npm: 5.5.1).
Please have a look at this, cause it is causing me some troubles following your redux course
This issue can be solved by using the below command.
npm install --save-dev webpack-dev-server
By using this command , my problem is solved.
I was having the same issue and the steps I took to resolve were: 1) put the below code snippet in my package.json, 2) delete the existing node_modules folder, and 3) "npm install". The issue is caused by npm not putting the required files in your node_modules folder. So you may need to delete the folder a couple times and run "npm install" afterwards or try a different command line interface. Here's the snippet for the package.json I used:
{ "name": "redux-simple-starter", "version": "1.0.0", "description": "Simple starter package for Redux with React and Babel support", "main": "index.js", "repository": "git@github.com:StephenGrider/ReduxSimpleStarter.git", "scripts": { "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js", "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test", "test:watch": "npm run test -- --watch" }, "author": "", "license": "ISC", "devDependencies": { "babel-core": "^6.2.1", "babel-loader": "^6.2.0", "babel-preset-es2015": "^6.1.18", "babel-preset-react": "^6.1.18", "chai": "^3.5.0", "chai-jquery": "^2.0.0", "jquery": "^2.2.1", "jsdom": "^8.1.0", "mocha": "^2.4.5", "react-addons-test-utils": "^0.14.7", "webpack": "^1.12.9", "webpack-dev-middleware": "^2.0.6", "webpack-dev-server": "^1.16.5", "webpack-hot-middleware": "^2.21.0" }, "dependencies": { "babel-preset-stage-1": "^6.1.18", "lodash": "^3.10.1", "react": "^0.14.3", "react-dom": "^0.14.3", "react-redux": "4.3.0", "react-router": "^2.0.1", "redux": "^3.0.4" } }
Webpack itself and webpack-dev-server went recently through major version bump. Downgrading webpack-dev-server in package.json to the previous version should do the trick for now.
- Change version of your webpack-dev-server to 2.11.1 in
package.json
"devDependencies": {
"webpack-dev-server": "^2.11.1"
}
- run
yarn install
@Montrail Before you ran
npm start
, did you runnpm install
to install the required dependencies?
Change to that directory and perform the same
very good i hope this helped me