12

I have been trying to get ESLint to work on a new Angular project in VS Code but it is failing to load "@typescript-eslint/eslint-plugin". I have spent the last 3 hours trying to figure out where the problem is and looked everywhere for a solution.

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.

Debugging steps that I have taken so far:

  • I uninstalled the global version as well as the extension, then reinstalled the extension and installed ESLint locally in the project folder.
  • I am using a fresh install of an Angular app that was created using Angular ng new command.
  • I ran eslint --debug /Users/Yahia/Desktop/Plugngrow-UI/png-ui/.eslintrc.js command. It results in no warnings other than a warning for ignoring the ".eslintrc.js" file while debugging.

Please note that ESLint works fine in another project which I downloaded from Angular docs while doing the introductory tutorial.

I have created a Github repo for the project if that helps with checking.

Please, excuse my novelty in programming and related tools.

2
  • Assuming you have that plugin in you package.json (as it is in you github repo), did you execute npm install to install a the needed plugins? Commented Dec 12, 2019 at 11:51
  • Yes, I did. I only got it to somehow work after installing specific old versions of [email protected] and [email protected]. It is still giving me some occasional errors here and there and it is not functioning as the latest version of Eslint on the other project, but it is working somehow. I came to believe it is a problem with creating a new Angular app through the CLI as it installs Tslint as its linter and that was creating some sort of conflict I guess. I am not honestly sure. Commented Dec 13, 2019 at 18:21

1 Answer 1

4

I just met with this problem yesterday. I would suggest you reinstall "@typescript-eslint/eslint-plugin" locally and see that help. You can also have fresh setup of eslintrc.js file and should be easy to fix.

This link was helpful. https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project

Not the answer you're looking for? Browse other questions tagged or ask your own question.