ERROR in xxx.js from UglifyJs
ERROR in xxx.js from UglifyJs
問題
ERROR in app.bundle.js from UglifyJs
Unexpected token: name ?element?, expected: punc ?;? [app.bundle.js:106,8]
在用webpack對(duì)代碼打包的時(shí)候報(bào)錯(cuò),在網(wǎng)上找到了類似的答案,還是沒有解決我的問題.
能解決大部分問題的鏈接
https://stackoverflow.com/questions/41254538/error-in-bundle-js-from-uglifyjs
http://www.cnblogs.com/aredleave/p/7586911.html
https://segmentfault.com/a/1190000011212544
按照以上方法對(duì)環(huán)境進(jìn)行重新配置,依然報(bào)錯(cuò)!
ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: 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'.報(bào)錯(cuò)原因
通過代碼報(bào)錯(cuò)原因是 babel-loader 版本問題,因?yàn)?babel-loader 用的最新的版本,和 UglifyJs 不兼容.
解決方法
通過運(yùn)行下面代碼對(duì)babel-loader進(jìn)行重新安裝(低版本).
npm install --save-dev babel-loader@7
通過修改后的package.json配置文件,親測可以正確打包,無報(bào)錯(cuò)現(xiàn)象.
{"name": "kankan","version": "1.0.0","description": "kankan","main": "webpack.config.js","scripts": {"start": "webpack-dev-server --open --config webpack.dev.js","build": "webpack --config webpack.prod.js"},"author": "kankan","license": "ISC","devDependencies": {"babel": "^6.23.0","babel-core": "^6.26.3","babel-loader": "^7.1.5","babel-preset-es2015": "^6.24.1","clean-webpack-plugin": "^2.0.1","css-loader": "^2.1.1","express": "^4.16.4","html-webpack-plugin": "^3.2.0","style-loader": "^0.23.1","uglifyjs-webpack-plugin": "^2.1.2","webpack": "^4.30.0","webpack-cli": "^3.3.1","webpack-dev-middleware": "^3.6.2","webpack-dev-server": "^3.3.1","webpack-manifest-plugin": "^2.0.4","webpack-merge": "^4.2.1"} }奇卡奇卡 哈哈哈
個(gè)人主頁:https://kankan.fun
明天的你一定會(huì)感謝現(xiàn)在拼命的自己!
總結(jié)
以上是生活随笔為你收集整理的ERROR in xxx.js from UglifyJs的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 每日打卡 22 11 16 CF 169
- 下一篇: LeetCode-----第二题----