简体   繁体   English

错误:找不到模块“ extract-text-webpack-plugin”

[英]Error: Cannot find module 'extract-text-webpack-plugin'

I've installed extract-text-webpack-plugin using this command in terminal sudo npm install -g extract-text-webpack-plugin and imported in webpack.config.js file, still i'm getting the error. 我已经在终端sudo npm install -g extract-text-webpack-plugin终端中使用此命令sudo npm install -g extract-text-webpack-plugin并导入了webpack.config.js文件,但仍然出现错误。

I also referred this question but didn't found any solution so i've posted new question. 我也提到了这个问题,但是没有找到任何解决方案,所以我发布了新问题。

Webpack - extract-text-webpack-plugin Cannot find module Webpack-extract-text-webpack-plugin找不到模块

Webpack.config.js file source code: 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"
    }
};

You have installed it for root, but not globally. 您已经为root用户安装了它,但没有全局安装。 Add -g flag to install or create package.json with npm init inside you project directory and then do npm install --save extract-text-webpack-plugin 添加-g标志以在项目目录中使用npm init安装或创建package.json,然后执行npm install --save extract-text-webpack-plugin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM