webpack的 extract text plugin for webpack 报错怎么回事?

官方的例子,都跑不起来?

const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
    entry: "./src/js/app.js",
    output: {
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") },
            { test: /\.styl$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader","stylus-loader") },
            { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
        ]
    },
    plugins: [
        new ExtractTextPlugin("styles.css")
    ]
};

错误信息:
图片描述

阅读 7.3k
5 个回答

可尝试安装extract-text-webpack-plugin依赖,命令如下:
npm install --save-dev extract-text-webpack-plugin@2.1.2

你看下你的node_modules下有没有webpack/lib/removeAndDo.js这个文件

没有的话,就npm install 或者直接把node_modules下全部删除,然后重新安装一下试试

新手上路,请多包涵

你需要参考一下 webpack 的 travis 配置,之前是需要强行 npm link webpack 的,但现在使用yarn就不用了

npm remove webpack -g
npm i webpack -D
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题