webpack打包报错Unexpected token

  最近项目要上线,需要对项目进行打包部署到服务器上面,在打包过程中npm run build后出现以下报错Unexpected token: punc (() [./~/[email protected]@element-ui/packages/col/src/col.js:23,0][static/js/0.3fbe30ed5a683f62d6bc.js:13890,10]

字面意思是报错来自UglifyJs,在col.js下23行出现了不期望的‘(’,打开col.js文件查看

不能识别这个函数的括号,上网查询后原来是UglifyJs不能解析ES6的问题,element-ui下的这个col文件使用了ES6的语法,所以导致无法解析,解决方法是在打包时,让babel去解析失败的包,打开webpack.base.conf.js,可以如下配置

然后再build一次,就大功告成。

时间: 2024-10-12 13:22:21

webpack打包报错Unexpected token的相关文章

webpack 打包报错:One CLI for webpack must be installed. These are recommended choices, delivered as separate packages

webpack 打包报错: One CLI for webpack must be installed. These are recommended choices, delivered as separate packages: 解决办法: 全局.局部安装个遍!具体什么原因还不清楚... 先全局安装webpack和webpack-clinpm install webpack -gnpm install webpack-cli -g再局部安装webpack和webpack-clinpm inst

关于Webpack打包报错Class constructor FileManager cannot be invoked witchout 'new'

前端代码部署一直是自己打包之后将文件用FileZilla上传到服务器上,现在改用运维基于到k8s docker镜像的发布,前端打包报错如下: 经查资料,报错原因是less升级导致的Bug 尝试升级less-loader到5.0.0已解决上面问题. 关于Webpack打包报错Class constructor FileManager cannot be invoked witchout 'new' 原文地址:https://www.cnblogs.com/vikki7/p/11392744.htm

webpack打包---报错内存溢出javaScript heap out of memory

今天, npm run build打包时,又报内存溢出了.所以记录一下,之前查了博客有一些解释. “报错CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory是 JavaScript堆内存不足,这里说的 JavaScript 其实就是 Node,我们都知道 Node 是基于V8引擎,在一般的后端开发语言中,在基本的内存使用上没有什么限制. 但是我去查阅了相关的资料才发现,在 Node 中通过 JavaScript

webpack打包报错

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.module has an unknown property 'loaders'. These properties are valid: object { exprContextCritical?, exprConte

webpack打包时报错:Support for the experimental syntax 'classProperties' isn't currently enabled

在写react项目创建class时使用了静态属性,但是在打包的时候报错: 根据报错提示下载@babel/plugin-proposal-class-properties包,并在.babelrc文件中的"plugins"里添加一项"@babel/plugin-proposal-class-properties" { "presets": ["@babel/preset-env", "@babel/preset-reac

从async await 报错Unexpected identifier 谈谈对上下文的理解

原文首发地址:http://www.cnblogs.com/lonhon/p/7518231.html 先简单介绍下async await: async/await是ES6推出的异步处理方案,目的也很明确:更好的实现异步编程.   详细见阮大神 ES6入门 现在说说实践中遇到的问题:使用await报错Unexpected identifier 先上代码: var sleep = function (time) { return new Promise(function (resolve, rej

Android打包报错 Export aborted because fatal lint errors were found. These are listed in the Lint View

打包时报如下错误: Export aborted because fatal lint errors were found. These are listed in the Lint View. Either fix these before running Export again,or turn off"Run full error check when exporting app" in the Android > Lint Error Checking preferenc

webpack编译报错:Module not found: Error: Cannot resolve 'file' or 'directory' ./../../node_modules..

在同事的mac电脑上,可以正常编译,拿到我这边就出错了(⊙﹏⊙) 好像是webpack在window下的一个bug,需要让 webpack 和你的项目保持在一个盘符下,参考. 解决方法: 修改config.js配置文件,在所有目录前加上path.join,参考1,参考2. webpack编译报错:Module not found: Error: Cannot resolve 'file' or 'directory' ./../../node_modules..

Unity3D 程序打包报错(程序是连接数据库进行处理的)

打包这个Unity3D的程序时出现错误(程序是由XML数据改成连接数据库): ArgumentException: The Assembly System.Configuration is referenced by System.Data. But the dll is not allowed to be included or could not be found. UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (Syst