Build project, the following error appears
ERROR in js/xxxxxx.js from UglifyJs
Unexpected token: [xxxx.js], expected: punc
It was found that uglifyjs could not resolve the problem of ES6
Solutions:
Upgrade uglifyjs version and modify package.json
"uglifyjs-webpack-plugin": "^1.0.0-beta.3",
Prod.conf.js
var UglifyJSPlugin = require('uglifyjs-webpack-plugin')
# Modify the plugin in plugins
new UglifyJSPlugin({
uglifyOptions: {
compress: {
drop_debugger: true, // Note debugger
drop_console: true, // Note console
pure_funcs:['console.log'] // remove console
},
},
sourceMap: false, // Removing the .map file generated after packaging
parallel: true,
}),
Runnpm run build
, Done!
Read More:
- [Solved] VScode Error: build constraints exclude all Go files in syscall\js
- Node js events.js:183 throw er; // Unhandled ‘error’ event
- vue VM682:1 Uncaught SyntaxError: Unexpected token u in JSON at position 0
- [Solved] webpack.config.js configuration encountered Error: Cannot find module’@babel/core’&&Cannot find module’@babel/plugin-transform-react-jsx’
- Refresh 404 after packaging Vue project, uncaught syntax error: unexpected token <
- R: Data frame index error “unexpected token”
- Template cannot be rendered due to the joint query of populate in mongoose: syntax error: unexpected token r in JSON at position 0
- How to Solve Error: “syntax error near unexpected token `newline’”
- [Solved] vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: “TypeError: Cannot read property ‘length‘
- Parsing error in eslint parsing: unexpected token [How to Solve]
- Error starting vue project these dependencies were not found:create in ./src/router/modules/md.js
- [Solved] ionic Build Error: Cannot load gulp tasks: Error: Error in module: .\gulpfile.js:
- Node.js operation mysql error Cannot enqueue Handshake after invoking quit
- [Solved] eslint Error: error Parsing error: Unexpected token <
- [Solved] Vite Project jenkins Auto Package Error: failed to load config from ../vite.config.js You installed esbuild on
- Vue Report Error #NULL! :no such file or directory,chmod….. [email protected] **\css- Beautify.js
- Ant Design Vue-Table Error: warning.js?2149:7 [How to Solve]
- The reason and solution for the error ECONNRESET of the httpClieint request of Node.js
- Chart.js Error: “Canvas is already in use. Chart …must be destroyed before the canvas can be reused”
- [Solved] Unity Publish WebGL Error: Unable to parse Build/webTest2.framework.js.gz