admin管理员组文章数量:1317131
I get an error when I run the program (vue3 + elements plus), but I don't know what's wrong with it. please help me.
Here is the error description and picture:
56:23 error Parsing error: Unexpected token, expected "," (11:23)
enter link description here
package.json
{
"name": "vueui",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"element-plus": "^2.1.3",
"vue": "^3.2.13"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.17.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:remended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
I get an error when I run the program (vue3 + elements plus), but I don't know what's wrong with it. please help me.
Here is the error description and picture:
56:23 error Parsing error: Unexpected token, expected "," (11:23)
enter link description here
package.json
{
"name": "vueui",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"element-plus": "^2.1.3",
"vue": "^3.2.13"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.17.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:remended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
Share
Improve this question
edited Mar 23, 2022 at 16:59
Jose Lora
1,3884 gold badges14 silver badges19 bronze badges
asked Mar 16, 2022 at 13:44
user18483459user18483459
391 gold badge1 silver badge4 bronze badges
4
- Place a ma after rules { } – Krausladen Commented Mar 16, 2022 at 14:05
- @Krausladen this would make the JSON invalid. – JSON Derulo Commented Mar 16, 2022 at 14:10
- You're getting an ESLint error reported. Probably the code builds and works just fine. Seems like you have not configured ESLint properly to work with TypeScript. – JSON Derulo Commented Mar 16, 2022 at 14:11
- You might want to add and configure typescript-eslint in your project. – JSON Derulo Commented Mar 16, 2022 at 14:12
3 Answers
Reset to default 6In the current configuration, eslint
cannot deal with TypeScript. The following steps enable TypeScript support.
- Run
npm install --save-dev @vue/eslint-config-typescript
- Adapt the ESLint config:
- Remove
"parser": "@babel/eslint-parser"
from theparserOptions
- Add
"@vue/typescript/remended"
to theextends
key
- Remove
Based on your file above, it would look like this:
{
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:remended",
"@vue/typescript/remended"
],
"parserOptions": {},
"rules": {}
}
Depending on your ESLint version, the installation of @vue/eslint-config-typescript
might result in a dependency conflict. With ESLint < 9 you'll have to install @vue/eslint-config-typescript@10
If Code Works Then You need to configure esLint if it throw an error then u need to place correctlly place it between {}
My issue was caused by find
. Vue error message is not help full
<p v-if="clients" class="text-sm text-gray-400">
No open or available details for
{{ clients.find((c: IClient) => c.id === selectedValue)[0]}}
</p>
I made a mistake find
will return IClient
object not an array
Solution: Double check your code
<p v-if="clients" class="text-sm text-gray-400">
No open or available details for
{{ clients.find((c: IClient) => c.id === selectedValue)?.pany }}
</p>
本文标签: javascripterror Parsing error Unexpected tokenexpected quotquotStack Overflow
版权声明:本文标题:javascript - error Parsing error: Unexpected token, expected "," - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742019192a2414346.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论