webpack3+和extract-text-webpack-plugin 时遇到 Cannot read property 'thisCompilation' of undefined 错误

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34672907/article/details/80137609

最近接手公司前端外包出去的的项目,然后在npm run build的时候遇到了两个问题。

第一点是  A complete log of this run can be found in:
npm ERR!     C:\Users\90422\AppData\Roaming\npm-cache\_logs\2018-04-28T09_26_42_435Z-debug.log

这个问题很简单,主要是npm自己报错了,更新npm 即可。(奇怪的只是这个项目需要这样,其他项目并没有这个问题,所以还需要查查原因)

命令为:npm i -g npm to update


第二点是更新完npm之后再次运行npm run build 发现还有报错,错误如下:

node_modules\extract-text-webpack-plugin\dist\index.js:183
    compiler.hooks.thisCompilation.tap(plugin, compilation => {
                   ^

TypeError: Cannot read property 'thisCompilation' of undefined

at ExtractTextPlugin.apply (D:\OA\node_modules\extract-text-webpack-plugin\dist\index.js:183:20)


网上百度了一下并没有解决方案,只有大部分报错叫更新一下extract-text-webpack-plugin

然后我看了一下给到我手的package.json发现版本是@4.0.0-beta,但大概可以猜到可能就是这个问题了,就动手解决

先卸载执行 npm uninstall --save-dev extract-text-webpack-plugin

再安装 npm install --save-dev extract-text-webpack-plugin

一定要记得先卸载再安装,不然装不上的哦!

之前开发并没有接触多少webpack搭建的项目,所以卡住了。希望跟我遇到一样问题的不用像我一样被卡住那么久

猜你喜欢

转载自blog.csdn.net/qq_34672907/article/details/80137609