Failed to load plugin '@typescript-eslint'...
See original GitHub issue( Been banging my head on this issue for a couple hours, tried different versions of node and npm, tried different config settings, any others getting this? Am I troubleshooting this all wrong?!)
expectations
When I run ESLint from the command line it works just fine:
eslint --ext .jsx,.js,.tsx,.ts --max-warnings 0 ./src
what I get
When I install the dbaeumer.vscode-eslint extension it doesn’t start & this is printed in the Output tab (Dropdown: ESLint)
[Info - 1:20:32 PM] ESLint server stopped.
[Info - 1:20:33 PM] ESLint server running in node v8.9.0
[Info - 1:20:34 PM] ESLint server is running.
[Info - 1:20:35 PM] ESLint library loaded from: /home/j/Repos/sam/sam-frontend/node_modules/eslint/lib/api.js
(node:2115) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to load plugin '@typescript-eslint' declared in 'sam-frontend/.eslintrc.js': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /home/j/Repos/sam/__placeholder__.js
Referenced from: /home/j/Repos/sam/sam-frontend/.eslintrc.js
(node:2115) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2115) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Failed to load plugin '@typescript-eslint' declared in 'sam-frontend/.eslintrc.js': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /home/j/Repos/sam/__placeholder__.js
Referenced from: /home/j/Repos/sam/sam-frontend/.eslintrc.js
from .eslintrc.js
module.exports = {
"parser": "@typescript-eslint/parser",
"extends": [
"airbnb",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"env": {
"browser": true,
"jest/globals": true
},
"plugins": [
"jest"
],
"rules": { ... }
}
from package.json
...
"eslint": "6.5.1",
"eslint-config-airbnb": "17.0.0",
"eslint-plugin-import": "2.13.0",
"eslint-plugin-jest": "21.18.0",
"eslint-plugin-jsx-a11y": "6.1.1",
"eslint-plugin-react": "7.14.2",
"@typescript-eslint/eslint-plugin": "2.3.3",
"@typescript-eslint/parser": "2.3.2",
...
from my vscode settings:
"eslint.runtime": "node"
node version: v8.9.0
npm version: 5.10.0
confusion & requesting help debugging?
I expect to get the same output when running from CLI vs through the plugin (especially when I set the node version to be the same as well), but there’s clearly further differences, and maybe some other configuration I’m missing? Can I get extended debug output from the vscode extension somewhere?
The error output Failed to load plugin '@typescript-eslint' declared in 'sam-frontend/.eslintrc.js': Cannot find module '@typescript-eslint/eslint-plugin' leads me to think I had a typo or a missing package, but I’ve double checked that so many times now I’m certain that I’ve got tunnelvision here, and that the problem is somewhere else entirely. Is there a version mismatch between the different moving parts? (eslint + @typescript-eslint/eslint-plugin + node + npm)
Is it because I’m using the *.js style of configuration file? (I tried switching once to a JSON .eslintrc, but I haven’t tried all permutations of this yet).
Am i even submitting this in the right place? My gut tells me this is an extension issue, but could it be a vscode issue?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Related StackOverflow Question
ok, now I feel pretty stupid, turns out I was just not setting the workingDirectories! (didn’t read the documentation thoroughly 🤦♂ )
with the above it works perfectly!
Good to see you found a solution. I guess you needed to run eslint in the terminal from
sam-frontendas well. In the workspace folder it very likely showed the same problems. In general if you have to cd into a directory to make eslint in the terminal work you need to specifyeslint.workingDirectories. There is a new value for working directories that does some auto inference which would have worked in your case as well ([{ "mode": "auto" }])