SyntaxError:?/xx.vue:?Unexpected?token,?expected?“,“錯(cuò)誤解決
錯(cuò)誤
本地老工程vue2.7.x+webpack4在升級(jí)webpack5的時(shí)候遇啟動(dòng)和打包報(bào)錯(cuò):
Syntax Error: SyntaxError: /xxxxx.vue Unexpected token, expected "," (1:8)
> 1 | [object Promise]
| ^
2 | export { render, staticRenderFns }最后才發(fā)現(xiàn)是prettier導(dǎo)致的。
推薦看看stackoverflow上面這個(gè)回答。Update Nodejs 14->18 — webpack have the same syntaxError: /.../xxx.vue: Unexpected token, expected "," (1:8) for ALL Vue 2 components in the project
導(dǎo)致原因
在prettier v3.0.0中,默認(rèn)值從es5更改為all
Default value changed from es5 to all in v3.0.0 Print trailing commas wherever possible in multi-line comma-separated syntactic structures. (A single-line array, for example, never gets trailing commas.) Valid options: "all" - Trailing commas wherever possible (including function parameters and calls). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or downlevel compilation. This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018). "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.). No trailing commas in type parameters in TypeScript. "none" - No trailing commas.
解決
- prettier插件版本回退到v2.8.8
"prettier":"v2.8.8"
- vue-loader配置prettify: false。
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
// vue loader在處理.vue模板時(shí)默認(rèn)不用prettier格式化
prettify: false,
},
},以上就是SyntaxError: /xx.vue: Unexpected token, expected “,“錯(cuò)誤解決的詳細(xì)內(nèi)容,更多關(guān)于SyntaxError vue 解決的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
vue雙向錨點(diǎn)實(shí)現(xiàn)過(guò)程簡(jiǎn)易版(scrollIntoView)
這篇文章主要介紹了vue雙向錨點(diǎn)實(shí)現(xiàn)過(guò)程簡(jiǎn)易版(scrollIntoView),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07
Vue腳手架安裝時(shí)遇到的無(wú)法安裝問(wèn)題詳解
開(kāi)發(fā)中遇到bug是在正常不過(guò)了,而程序也基本都是bug堆里爬出來(lái)的,下面這篇文章主要給大家介紹了關(guān)于Vue腳手架安裝時(shí)遇到的無(wú)法安裝問(wèn)題的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07
vue treeselect獲取當(dāng)前選中項(xiàng)的label實(shí)例
這篇文章主要介紹了vue treeselect獲取當(dāng)前選中項(xiàng)的label實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-08-08
vue跳轉(zhuǎn)頁(yè)簽傳參并查詢(xún)參數(shù)的保姆級(jí)教程
這篇文章主要介紹了vue跳轉(zhuǎn)頁(yè)簽傳參并查詢(xún)參數(shù)的保姆級(jí)教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-04-04
vue.js中created()與activated()的個(gè)人使用解讀
這篇文章主要介紹了vue.js中created()與activated()的個(gè)人使用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07
一篇文章教你簡(jiǎn)單使用Vue的watch偵聽(tīng)器
這篇文章主要為大家介紹了Vue watch偵聽(tīng)器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2021-12-12
vue動(dòng)態(tài)組件之:is在組件中的使用場(chǎng)景
這篇文章主要介紹了vue動(dòng)態(tài)組件之:is在組件中的使用場(chǎng)景,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-07-07
vue-resource post數(shù)據(jù)時(shí)碰到Django csrf問(wèn)題的解決
這篇文章主要介紹了vue-resource post數(shù)據(jù)時(shí)碰到Django csrf問(wèn)題的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03

