Javascript Webpack - extract-text-webpack-plugin 找不到模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33998894/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 15:47:12  来源:igfitidea点击:

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

javascriptnode.jsreactjssasswebpack

提问by Luca Mormile

webpack.config.js

webpack.config.js

var ExtractTextPlugin = require("extract-text-webpack-plugin");

I immediately receive this error if I just implement the plugin:

如果我只是实现插件,我会立即收到此错误:

module.js:339
    throw err;
    ^

Error: Cannot find module 'webpack/lib/ConcatSource'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/lucamormile/Documents/Lavori/Webapps/React/webpack_test/node_modules/extract-text-webpack-plugin/index.js:5:20)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

What did i forgot?

我忘记了什么?

回答by htanjo

Do you have webpackmodule on your project?
If not, install it locally (not globally):

webpack你的项目有模块吗?
如果没有,请在本地安装(不是全局安装):

$ npm install webpack [--save-dev]

extract-text-webpack-pluginneeds webpackas peer dependency, but npm 3 doesn't install peer dependencies automatically.

extract-text-webpack-plugin需要webpack作为对等依赖项,但 npm 3 不会自动安装对等依赖项。

回答by Sandy Duan

You can try this command which I found on https://www.npmjs.com/package/extract-text-webpack-plugin

你可以试试我在https://www.npmjs.com/package/extract-text-webpack-plugin 上找到的这个命令

npm i extract-text-webpack-plugin

回答by linzhi

I solve it by use

我通过使用解决它

npm install extract-text-webpack-plugin --save-dev

npm install extract-text-webpack-plugin --save-dev

回答by Victor Joseph

Use $ npm i -D extract-text-webpack-plugin@nextand this would solve your issue

使用$ npm i -D extract-text-webpack-plugin@next,这将解决您的问题

Let me know if this worked.

让我知道这是否有效。

https://github.com/webpack/webpack/issues/6568

https://github.com/webpack/webpack/issues/6568

回答by Azeez Bello

Simple fix

简单的修复

npm install extract-text-webpack-plugin --save-dev

https://www.npmjs.com/package/extract-text-webpack-plugin

https://www.npmjs.com/package/extract-text-webpack-plugin

回答by Play Mobil

Running npm i node-sassmight solve your problem

跑步npm i node-sass或许能解决你的问题