You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode运行ESLint报错无法加载vue插件问题求助

解决方案

  • 先清理并重新安装依赖:删除项目下的node_modules文件夹、package-lock.json(或yarn.lock)文件,在项目根目录执行npm install(或对应包管理工具的安装命令),确保所有依赖安装完整无缺失。
  • 修正VSCode ESLint插件配置:如果你打开VSCode的工作区根目录是frontend文件夹的上层目录,原有auto模式的工作目录识别会出错,将.vscode/settings.json调整为如下内容:
{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "eslint.workingDirectories": ["./frontend"],
  "eslint.useLocalEsLint": true,
  "eslint.nodePath": "./node_modules"
}
  • 补充ESLint配置:在eslintrc.js顶层新增vue专属解析器配置,原有配置保持不变即可:
module.exports = {
  root: true,
  // 新增vue文件解析器配置
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: "babel-eslint",
    sourceType: 'module'
  },
  // 其余原有配置保持不变
  env: {
    node: true,
  },
  extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
  rules: {
    "no-console": process.env.NODE_ENV === "production" ? "off" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "off" : "off",
  },
  overrides: [
    {
      files: ["**/__tests__/*.{j,t}s?(x)", "**/tests/unit/**/*.spec.{j,t}s?(x)"],
      env: {
        mocha: true,
      },
    },
  ],
};
  • 所有配置修改完成后,重启VSCode窗口或者重新加载ESLint插件即可生效。

内容的提问来源于stack exchange,提问作者Robertas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 03:36:02