【问题标题】:Error: Cannot find module 'extract-text-webpack-plugin'错误:找不到模块“extract-text-webpack-plugin”
【发布时间】:2016-09-15 01:02:29
【问题描述】:

我已经在终端 sudo npm install -g extract-text-webpack-plugin 中使用此命令安装了 extract-text-webpack-plugin 并导入到 webpack.config.js 文件中,但仍然出现错误。

我也提到了这个问题,但没有找到任何解决方案,所以我发布了新问题。

Webpack - extract-text-webpack-plugin Cannot find module

Webpack.config.js 文件源代码:

/* Custom Config */
var ProgramID = '1111';

/* Default Config */
var webpack = require('webpack');
var path = require('path');
var polyfill = require("babel-polyfill");
var ExtractTextPlugin = require("extract-text-webpack-plugin");

var BUILD_DIR = path.resolve(__dirname, 'build/Programs/' + ProgramID);
var APP_DIR = path.resolve(__dirname, 'src/import');

module.exports = {
  entry: [
    'babel-polyfill',
    'webpack-dev-server/client?http://localhost:8080/',
    APP_DIR + '/import.js'
  ],
  output: {
    path: BUILD_DIR + '/',
    filename: '/js/bundle.js',
    publicPath: '../Programs/' + ProgramID
  },
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loaders: ['react-hot', 'babel?presets[]=es2015,presets[]=react,plugins[]=transform-runtime'],
      exclude: /node_modules/
    }, {
      test: /\.css$/,
      loader: ExtractTextPlugin.extract("style-loader", "css-loader")
    }, {
      test: /\.scss$/,
      loaders: ["style", "css", "sass"]
    }, {
      test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif)$/,
      loader: 'file-loader?name=/images/[name].[ext]'
    }]
  },
  plugins: [
    new ExtractTextPlugin("style.css"),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  process: function(path, filename) {
    if (filename.indexOf('node_modules') === -1) {
      path = babelJest.process(path, filename);
      path = webpackAlias.process(path, filename);
    }
    return path;
  },
  externals: {
        "jquery": "jQuery"
    }
};

【问题讨论】:

    标签: javascript webpack webpack-style-loader


    【解决方案1】:

    您已经为 root 安装了它,但不是全局安装。添加 -g 标志以在您的项目目录中安装或创建带有 npm init 的 package.json,然后执行 npm install --save extract-text-webpack-plugin

    【讨论】:

      猜你喜欢
      • 2016-03-04
      • 2019-04-23
      • 2018-01-26
      • 2017-09-30
      • 2017-07-11
      • 1970-01-01
      • 2018-09-09
      • 2018-05-29
      • 2017-06-18
      相关资源
      最近更新 更多