简体   繁体   English

错误解析错误:意外的令牌,预期的“,”

[英]error Parsing error: Unexpected token, expected ","

I get an error when I run the program (vue3 + elements plus), but I don't know what's wrong with it.运行程序时出现错误(vue3 + elements plus),但我不知道它有什么问题。 please help me.请帮我。

Here is the error description and picture:这是错误描述和图片:

56:23 error Parsing error: Unexpected token, expected "," (11:23) 56:23 错误解析错误:意外的令牌,预期的“,”(11:23)

在此处输入图像描述


enter link description here 在此处输入链接描述


package.json 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:recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead",
    "not ie 11"
  ]
}

If Code Works Then You need to configure esLint if it throw an error then u need to place correctlly place it between {} If Code Works Then You need to configure esLint if it throw an error 然后你需要将它正确放置在 {}

In the current configuration, eslint cannot deal with TypeScript.在当前配置下, eslint无法处理 TypeScript。 The following steps enable TypeScript support.以下步骤启用 TypeScript 支持。

  • Run npm install --save-dev @vue/eslint-config-typescript运行npm install --save-dev @vue/eslint-config-typescript
  • Adapt the ESLint config:调整 ESLint 配置:
    • Remove "parser": "@babel/eslint-parser" from the parserOptionsparserOptions中删除"parser": "@babel/eslint-parser"
    • Add "@vue/typescript/recommended" to the extends key"@vue/typescript/recommended"添加到extends

Based on your file above, it would look like this:根据您上面的文件,它看起来像这样:

{
  "root": true,
  "env": {
    "node": true
  },
  "extends": [
    "plugin:vue/essential",
    "eslint:recommended",
    "@vue/typescript/recommended"
  ],
  "parserOptions": {},
  "rules": {}
}

Depending on your ESLint version, the installation of @vue/eslint-config-typescript might result in a dependency conflict.根据你的 ESLint 版本, @vue/eslint-config-typescript的安装可能会导致依赖冲突。 With ESLint < 9 you'll have to install @vue/eslint-config-typescript@10使用 ESLint < 9 你必须安装@vue/eslint-config-typescript@10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM