【前端】Webpack构建Vue项目踩过的坑

编程入门 行业动态 更新时间:2024-10-24 17:19:09

【前端】Webpack构建Vue<a href=https://www.elefans.com/category/jswz/34/1771421.html style=项目踩过的坑"/>

【前端】Webpack构建Vue项目踩过的坑

问题1: Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead

解决方法:
webpack4.0以上用3.x extract-webpack-plugin 打包会不兼容,extract-webpack-plugin升级就可以了。

npm install --save-dev extract-text-webpack-plugin@4.0.0-beta.0

问题2: babel安装问题,Cannot find module ‘@babel/core’ babel-loader@8 requires Babel 7.x (the package '@babel/c

Cannot find module '@babel/core'babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.ou should install 'babel-loader@7'.

解决方法

  • 原因:babel-loader和babel-core版本不对应造成的;
    • babel-loader 8.x 对应 babel-core 7.x
    • babel-loader 7.x 对应 babel-core 6.x

查看下自己的babel-loader和babel-core版本号是否对应,否则删除已经安装的对应的node包和相应配置,然后执行下面的命令(这里安装的是7.x的babel-loader),重新安装,即可解决:

npm install --save -dev babel-loader@7

问题3:
./node_modules/_vue-loader@15.7.1@vue-loader/lib/index.js You may need an additional load…

ERROR in ./src/login.vue?vue&type=template&id=19e76240& 2:0
Module parse failed: Unexpected token (2:0)
File was processed with these loaders:* ./node_modules/_vue-loader@15.7.1@vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.

解决方法
原因:Vue-loader在15.*之后的版本都是 vue-loader的使用都是需要伴生 VueLoaderPlugin的,所以我们要在这两个的基础上再去下载这个插件。

npm install --save-dev vue-loader-plugin

然后在配置文件(webpack.config.js)中要加上:

// webpack.config.js
const VueLoaderPlugin = require('vue-loader/lib/plugin')module.exports = {// ...plugins: [new VueLoaderPlugin()]
}

更多推荐

【前端】Webpack构建Vue项目踩过的坑

本文发布于:2024-02-25 02:03:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1697413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   Webpack   Vue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!