我想配置我的 GLOBAL eslint 安装以在 Visual Studio Code 中对我的 typescript 项目进行 lint。
所以我安装了 Visual Studio Code 扩展“ESLint”并安装了 ESLint
npm install -g eslint
根据https://www.npmjs.com/package/@typescript-eslint/eslint-plugin它也需要@typescript-eslint/eslint-plugin
全局安装,所以我跑了
npm install -g @typescript-eslint/parser @typescript-eslint/eslint-plugin
将它与 ts parse 一起安装@typescript-eslint/parser
。
接下来,我添加了一个非常简单的 .eslintrc 文件:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": { }
}
但是,只要我eslint .
在我的项目目录中运行,我就会得到:
Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.js': Cannot find module '@typescript-eslint/parser'
接下来我尝试删除全局安装的解析器并将其安装在本地,但这也不起作用:现在我的全局eslint 安装可以找到我的本地解析器,但是解析器需要另一个本地安装 typescript、eslint 等。我想运行不过,全球的一切。
我根本无法让它工作!任何人都可以帮助我完成这个过程吗?