找不到模块webpack-dev-server.js

时间:2016-08-19 08:49:06

标签: reactjs

通过在git bash中运行命令webpack-dev-server,在运行简单的todo应用程序时出现问题。这是我的webpack.config.js

var webpack =  require("webpack");
    var path = require("path");

    module.exports = {
        devtool : 'inline-source-map',
        entry   :[
                'webpack-dev-server/client?http://127.0.0.1:8080/',
                'webpack/hot/only-dev-server',
                './src'
        ],
        output :{
            path:path.join(__dirname,'public'),
            filename :'bundle.js'
        },
        resolve :{
            modulesDirectories :['./node_modules','src'],
            extensions :['','.js']
        },
        module:{
            loaders :[{
                test : /\.jsx?$/,
                exclude :/node_modules/,
                loaders:['react-hot','babel?presets[]=react,presets[]=es2015']
            }]
        },
        plugins :[
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NoErrorsPlugin()
        ]

    };

实际是:error cannot find node modules inside the git Directory我已在本地安装了webpack-dev-server。

我在屏幕截图中附加了错误     [1]:http://i.stack.imgur.com/Uexvg.png

3 个答案:

答案 0 :(得分:0)

readme.md告诉您转到localhost:8080,但https://github.com/michaelcheng429/react-tutorial-todos/blob/master/server.js文件设置为localhost:3000。所以转到localhost:3000它应该可以工作。

答案 1 :(得分:0)

在这里你可以看到。我对您的代码及其在端口8080上的工作进行了一些更改。

https://github.com/OnlyRefat/Example

您需要在全局和本地安装webpack和webpack-dev-server。

答案 2 :(得分:-1)

我认为您不需要'webpack-dev-server/client?http://127.0.0.1:8080/'作为配置中的入口点。尝试删除它。

您可能还需要全局安装webpack npm install webpack-dev-server -g,然后尝试运行webpack-dev-server