Tag Archives: Unexpected token

Unexpected token of webpack package error

The project needs to be packaged and deployed to the server recently. During the packaging process, the following unexpected token appears after NPM run build: punc (() [/~/_element- [email protected] @element-ui/packages/col/src/col.js:23,0][static/js/0.3fbe30ed5a683f62d6bc.js:13890,10]

It literally means that the error is from uglifyjs. An unexpected ‘(‘ appears in line 23 under col.js. Open the col.js file to view it

The parentheses of this function cannot be recognized. After online query, it turns out that uglifyjs cannot parse ES6. The col file under element UI uses ES6 syntax, so it cannot be parsed. The solution is to ask Babel to parse the failed package during packaging. Open webpack.base.conf.js, which can be configured as follows

Then build again and you’re done