javascript - ESLint 无法识别“@typescript-eslint/eslint-plugin”
问题描述
我一直试图让 ESLint 在 VS Code 中处理一个新的 Angular 项目,但它无法加载“@typescript-eslint/eslint-plugin”。在过去的 3 个小时里,我一直在试图找出问题所在,并到处寻找解决方案。
Failed to load plugin '@typescript-eslint' declared in 'png-ui/.eslintrc.js': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /Users/Yahia/Desktop/Plugngrow-UI/__placeholder__.js
Referenced from: /Users/Yahia/Desktop/Plugngrow-UI/png-ui/.eslintrc.js
Happened while validating /Users/Yahia/Desktop/Plugngrow-UI/png-ui/.eslintrc.js
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure '@typescript-eslint/eslint-plugin' is installed globally as well.
3. If ESLint is installed locally, then '@typescript-eslint/eslint-plugin' isn't installed correctly.
Consider running eslint --debug /Users/Yahia/Desktop/Plugngrow-UI/png-ui/.eslintrc.js from a terminal to obtain a trace about the configuration files used.
到目前为止我已采取的调试步骤:
- 我卸载了全局版本以及扩展,然后重新安装了扩展并在项目文件夹中本地安装了 ESLint。
- 我正在使用使用 Angular
ng new
命令创建的全新安装的 Angular 应用程序。 - 我跑了
eslint --debug /Users/Yahia/Desktop/Plugngrow-UI/png-ui/.eslintrc.js
命令。除了在调试时忽略“.eslintrc.js”文件的警告之外,它不会导致任何警告。
请注意,ESLint 在我做介绍性教程时从 Angular 文档下载的另一个项目中运行良好。
如果这有助于检查,我已经为该项目创建了一个Github 存储库。
请原谅我在编程和相关工具方面的新颖性。
解决方案
我昨天刚遇到这个问题。我建议您在本地重新安装“@typescript-eslint/eslint-plugin”并查看帮助。您还可以重新设置 eslintrc.js 文件,并且应该很容易修复。
这个链接很有帮助。 https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project
推荐阅读
- python - 如何从正则表达式结果中删除不必要的字符?
- laravel - 表单数据向服务器发送空请求
- websocket - 移动应用程序中的 Websocket 替代品?
- python - Pandas DataFrame:根据列中的条件删除重复的行
- r - 如何在 R 中创建变量来计算另一个变量的一个变量的值的数量?
- angular - 单独渲染元素中的 Micro UI Angular 问题
- android - Spinner 在片段中添加/获取价值
- amazon-web-services - AWS CLI 创建 ECR 存储库
- c# - 使用开箱即用的 WPF DataGrid 显示预处理的动态数据
- mysql - 无法在mysql表中插入主键