vs-code-prettier-eslint: Error: Cannot find module '@typescript-eslint/parser'
Describe the bug
I have a v4.0.0-beta
version of extension, and on formatting action it shows me the error:
Error: Cannot find module '@typescript-eslint/parser'
Require stack:
- /home/user/.vscode-server/extensions/rvest.vs-code-prettier-eslint-4.0.0-beta/dist/extension.js
- /home/user/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/loader.js
- /home/user/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/bootstrap-amd.js
- /home/user/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/bootstrap-fork.js
But the ‘@typescript-eslint/parser’ package is installed locally:
$ yarn list --pattern '@typescript-eslint/parser'
yarn list v1.22.5
├─ @typescript-eslint/parser@5.8.1
└─ prettier-eslint@10.1.1
└─ @typescript-eslint/parser@3.10.1
To Reproduce Steps to reproduce the behavior:
- Install the
v4.0.0-beta
version of the extension. - Install ‘@typescript-eslint/parser’ via
yarn add @typescript-eslint/parser@^5.0.1
- Select “Format Document With » Prettier ESLint”.
- See the error
Versions (please complete the following information):
- Visual Studio Code: Version: 1.63.2 Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3 Date: 2021-12-15T09:39:46.686Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Linux x64 5.13.0-22-generic
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (9 by maintainers)
Commits related to this issue
- fix #27 — committed to zhangzhuang15/vs-code-prettier-eslint by zhangzhuang15 a year ago
thank you this fixed it for me. for anyone else making that change just remember a
.js
usesmodule.exports
which you add before the{
of the json content.js
@MurzNN Rename your
.eslintrc
to.eslintrc.js
to make it a JavaScript file. Then addunder
You are getting an error because the ESLint TS parser cannot find your
tsconfig.json
I tried to see where
require.resolve
is looking for and I got:…which is the expected behavior from Node AFAIK. But no, there’s no such package in there :p
Should this extension add @typescript-eslint/parser as a dependency? Otherwise, how can we use the locally installed package (from the current project) or the one that has been globally installed?
Edit: I suspect that we might have the same issue with
vue-eslint-parser
.See https://github.com/prettier/prettier-eslint/blob/master/src/index.js#L126
@idahogurl Succeed, Very Nice. (^o^)/~
🚀 UPDATE: Fixed it! 🥳
I just removed the unused jsx-a11y plugin from my ESLint config.
I wasn’t using JSX in my project but it had the following ESLint config:
Because I had copied the
.eslintrc.js
file from another project.Also I didn’t have the
eslint-plugin-jsx-a11y
package installed, installing it also fixes the issue.Original comment:
Getting this error with the latest pre-release version (v5.0.1):
The following didn’t work:
@the-vampiire That code is from ‘prettier-eslint’. It gets bundled during the build. I’ll take a look later today hopefully.