前端自动化构建webpack:踩坑专题

1.

安装webpack的时候 遇到的情况; 直接按照提示安装 提示Module webpack-cli 不存在

One CLI for webpack must be installed. These are recommended choices, delivered as separate packages: 
- webpack-cli (https://github.com/webpack/webpack-cli) 
The original webpack full-featured CLI. 
- webpack-command (https://github.com/webpack-contrib/webpack-command) 
A lightweight, opinionated webpack CLI. 
We will use “npm” to install the CLI via “npm install -D”. 
Which one do you like to install (webpack-cli/webpack-command):

解决

. npm install  webpack-cli -g

 2。

ERROR in ./main.js
Module not found: Error: Can't resolve 'style-loader' in 'E:\程序\Web\webpack\he
llo,webpack'
 @ ./main.js 1:0-22

未安装loader模块

解决方法:
cnpm install css-loader style-loader

3.

描述:在webpack4.0中使用“extract-text-webpack-plugin”之后,生产环境下报错,如何解决

 (node:4728) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(node:4728) DeprecationWarning: Tapable.apply is deprecated. Call apply on the plugin directly instead
/Users/x-kxem/myWorkSpace/vue-ssr-tech/node_modules/webpack/lib/Chunk.js:460
throw new Error(
^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
    at Chunk.get (/Users/x-kxem/myWorkSpace/vue-ssr-tech/node_modules/webpack/lib/Chunk.js:460:9)
    at /Users/x-kxem/myWorkSpace/vue-ssr-tech/node_modules/extract-text-webpack-plugin/dist/index.js:176:47 

 

解决方法:输入命令npm install extract-text-webpack-plugin@next

具体原因: 因为版本的冲突(extract-text-webpack-plugin在4.x中已经被弃用),必须要找到extract-text-webpack-plugin对应的webpack版本,以上的方法是目前一个通用的解决办法。但是已经有替代的产品了,详情请在

https://blog.csdn.net/harsima/article/details/80819747或https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/701查看

4.遇到解决不了的问题,就把项目里的插件脚手架都给删掉,重新安装,因为npm有时总会出现莫名其妙的错误。

5.

 

你可能感兴趣的:(前端自动化构建webpack)