首页 > 其他分享 >SyntaxError: /xxxx.vue: Unexpected token, expected “,“,[object Promise]export { render, staticRende}

SyntaxError: /xxxx.vue: Unexpected token, expected “,“,[object Promise]export { render, staticRende}

时间:2023-08-18 23:22:14浏览次数:35  
标签:vue xxxx render commas token Unexpected prettier trailing

本地老工程vue2.7.x+webpack4在升级webpack5的时候遇启动和打包报错:

Syntax Error: SyntaxError: /xxxxx.vue Unexpected token, expected "," (1:8)

> 1 | [object Promise]
    |         ^
  2 | export { render, staticRenderFns } 

最后才发现是prettier导致的。

推荐看看stackoverflow上面这个回答。Update Nodejs 14->18 — webpack have the same syntaxError: /.../xxx.vue: Unexpected token, expected "," (1:8) for ALL Vue 2 components in the project

导致原因:

在prettier v3.0.0中,默认值从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.

解决方法1

prettier插件版本回退到v2.8.8

"prettier":"v2.8.8"

解决方法2

vue-loader配置prettify: false。

   {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          // vue loader在处理.vue模板时默认不用prettier格式化
          prettify: false,
        },
   },

标签:vue,xxxx,render,commas,token,Unexpected,prettier,trailing
From: https://www.cnblogs.com/tianmiaogongzuoshi/p/17641809.html

相关文章

  • vue3 vite后台管理模板项目打包报错 Some chunks are larger than 500 KiB after mini
    ​ 1、错误原因分析:超过块大小限制,块大小默认500KB2、解决办法:在vite.config.js中增加output配置项build:{chunkSizeWarningLimit:1500,//调整包的大小rollupOptions:{output:{//最小化拆分包manualChunks(id){......
  • Vue中使用Element
    Vue中使用Element.UI菜单完成主体页面搭建一.搭建ElementUI基础环境(基于脚手架)1.新建空的文件夹,文件夹命名自定义2.在文件资源管理器上方输入cmd3.然后在控制台中输入vuecreate(自定义名称)注意:只支持小写输入完后按Enter4.在第一个选择项中选择Manuallyselectfeatures5.第......
  • vue3常见的难点
    vue中params和query的区别,以及具体用法:https://blog.csdn.net/weixin_42282727/article/details/107505014route、router区别:https://blog.csdn.net/m0_67948827/article/details/127051410......
  • vue3新语法糖——setup script
    vue3新语法糖——setupscriptCoCoyY12021-03-2712:5241480 前言vue3上线已经很久了,许多小伙伴应该都已经使用过vue3了。那么在使用vue3compositionAPI的时候有没有觉得整个过程会比较繁琐呢。比如当你定义了一个方法,然后发现模板需要使用该方法,然后就必须将方法返回......
  • vue2公共组件=》筛选条件
    源码<template><divclass="c__filter":style="`height:${showFilter?'auto':'47px'}`"v-if="filterNum>0"ref="tableFilter"><divclass="c_filte......
  • vue+echarts
    <template><div><divref="chart"style="width:50%;height:376px"></div><divref="chart1"style="width:50%;height:376px"></div></div></template><sc......
  • vue使用echarts画图
    <template><div><divclass="container"><divid="echart"></div></div></div></template><script>exportdefault{data(){return{};},//页面初始化挂载d......
  • vue无缝循环轮播
    在网上看了几个无缝循环轮播的实现方法,使用方法都比较复杂,所以这里提供一种比较简单的实现方式gitee:https://gitee.com/philippines-kisses-snow/rotation结构和理论梳理理论轮播的原理就是通过translateY/translateX移动轮播容器+过渡达到轮播项上下左右轮播效果的,为了达......
  • 谈谈Vue3中的ref和reactive
    一、是什么?ref和reactive是Vue3中用来实现数据响应式的API一般情况下,ref定义基本数据类型,reactive定义引用数据类型(我喜欢用它来定义对象,不用它定义数组,原因后面讲)我理解的ref本质上是reactive的再封装二、先聊reactivereactive定义引用数据类型(以对象和数组举例),它能够将复......
  • ElementUI——vue2+element-ui 2.x的动态表格和表单
    前言一个基于vue2.x+element-ui2.x版本的项目,里面都是CURD的东西,但是前人并未封装组件,而是直接CV,现在要新增一个大模块的功能,就想着封装个组件,后面再基于这个组件对老项目进行改造;虽然是一个大模块,但是功能还是比较简单的,结构如下;内容?>这纯粹是个简单的DEMO,如果你需要......