简体   繁体   中英

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

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?

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

$ npm install webpack [--save-dev]

extract-text-webpack-plugin needs webpack as peer dependency, but npm 3 doesn't install peer dependencies automatically.

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

npm i extract-text-webpack-plugin

我通过使用解决它

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

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

Let me know if this worked.

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

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?

运行npm i node-sass可能会解决您的问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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