-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Cannot find module '@typescript-eslint/parser' #27
Comments
Seems this happens in projects, where have several root folders opened, in project with single folder - all works well. |
@MurzNN What version of ESLint do you have installed? Could you provide your ESLint config file? |
I have the same issue with ESLint 6.8.0 and the current stable plugin (3.0.4). I also have multiple projects in the same folder but since it's a monorepo I really want to have all of them opened at the same time. I tried to open a single package from it and I still have this issue. I feel like it's an issue with |
I have module.exports = {
parser: '@typescript-eslint/parser',
env: {
browser: true,
es6: true,
node: true,
jest: true,
'cypress/globals': true,
},
plugins: [
'react',
'react-hooks',
'jest',
'cypress',
'import',
'@typescript-eslint',
'@preconstruct/format-js-tag',
],
settings: {
react: {
version: 'detect',
},
},
rules: {
curly: ['error', 'multi-line'],
'jsx-quotes': 'error',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-unused-expressions': 'error',
'react-hooks/rules-of-hooks': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
vars: 'all',
},
],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/__tests__/**/*',
'**/*test.*',
'**/tests/**/*',
'**/build/**/*',
`packages/fields/src/**/filterTests.*`,
'**/test-fixtures.*',
],
},
],
'import/no-unresolved': 'error',
'import/order': 'error',
'jest/valid-describe': 'off',
'jest/valid-expect': 'off',
'jest/no-conditional-expect': 'off',
'jest/no-standalone-expect': 'off',
'jest/expect-expect': 'off',
'jest/no-export': 'off',
'jest/valid-title': 'off',
'jest/no-try-expect': 'off',
'jest/no-disabled-tests': 'error',
'object-curly-spacing': ['error', 'always'],
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'react/jsx-boolean-value': 'warn',
'react/jsx-no-undef': 'error',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-wrap-multilines': 'warn',
'react/no-did-mount-set-state': 'warn',
'react/no-did-update-set-state': 'warn',
'react/no-unknown-property': 'warn',
'react/react-in-jsx-scope': 'error',
'react/self-closing-comp': 'warn',
'react/sort-prop-types': 'warn',
semi: 'error',
strict: 'off',
'no-restricted-syntax': [
'error',
{
// Curious why we have this rule?
// - Enums only work for a subset of use cases that unions of string literals + objects work for and learning one language feature is easier than learning two language features
// - Enums are a new language feature which have runtime semantics which means they change TypeScript from JS + types to JS + types + extra language features which is harder to teach without clear advantages for this specific feature
selector: 'TSEnumDeclaration',
message: 'Use a union of string literals instead of an enum',
},
],
'@typescript-eslint/ban-types': [
'error',
{
extendDefaults: false,
types: {
Function:
'`Function` types are unsafe. Use more specific function types instead. e.g. (arg: number) => string',
String: {
message:
'The `String` type refers to the String object which is probably not what you want, you probably want `string` instead which refers to the string primitive type.',
fixWith: 'string',
},
ComponentType: reactComponentTypeMessage,
FC: reactComponentTypeMessage,
SFC: reactComponentTypeMessage,
'React.ComponentType': reactComponentTypeMessage,
'React.FC': reactComponentTypeMessage,
'React.SFC': reactComponentTypeMessage,
},
},
],
'@preconstruct/format-js-tag/format': 'error',
},
extends: ['plugin:jest/recommended'],
// Disable some rules for (code blocks within) Markdown docs
overrides: [
{
files: ['**/*.md'],
rules: {
'no-unused-vars': 'off',
'no-undef': 'off',
},
},
{
files: ['packages/fields/src/**/*.{js,ts,tsx}'],
rules: {
'import/no-commonjs': 'error',
},
},
{
files: ['**/*.{ts,tsx}'],
rules: {
// TypeScript already checks for the following things and they conflict with TypeScript
'import/no-unresolved': 'off',
'no-undef': 'off',
},
},
],
}; |
I tried to see where
...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 See https://github.com/prettier/prettier-eslint/blob/master/src/index.js#L126 |
Yes, I'm using Lerna. |
@MurzNN I created an example repo to try to reproduce your issue. https://github.com/idahogurl/example-repo In VS Code, you go to I gave you write access so feel free to adjust the project to match your setup. @neolitec Did my comments about Lerna help? If not feel free to create a demo repo that reproduces the issue. |
@idahogurl I didn't have the time to investigate more on my first project. |
@neolitec Could you provide your ESLint config and package.json? The extension does not support ESLint 8+. They made some breaking changes to their API and Prettier-ESLint has not been updated. I was going to create a PR for them. |
Hello, I'm also having this issue. I'm using version 3.1.0 of the plugin with pnpm and eslint@7.32.0. Here's my package.json
Here's my .eslintrc
|
@MurzNN Rename your tsconfigRootDir: __dirname under "project": "./tsconfig.json" You are getting an error because the ESLint TS parser cannot find your |
Hi I am also having this issue and have a pretty stripped down list of dependencies. I also tried applying the fixes you reccomended @murmanox package.json
eslint.rc
prettierrc.json
tsconfig.json
|
thank you this fixed it for me. for anyone else making that change just remember a
module.exports = { ... } |
@claritise Did you name your file |
@idahogurl i am now getting this error again but only after adding the following rules: "import/order": [
"error",
{ "newlines-between": "always", "alphabetize": false }
],
"sort-imports": [
"error",
{
"memberSyntaxSortOrder": ["none", "all", "single", "multiple"],
}
],
module.exports = {
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": __dirname,
"project": "./tsconfig.json"
},
"env": {
"es6": true,
"jest": true
},
"ignorePatterns": [
"node_modules",
"build",
"coverage",
".eslintrc.js",
"jest.config.js"
],
"plugins": [
"import",
"eslint-comments",
"@typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:jest/recommended",
"plugin:jest/style",
"prettier"
],
"globals": {
"BigInt": true,
"console": true,
"WebAssembly": true
},
"rules": {
"padding-line-between-statements": ["error", { "blankLine": "always", "prev": "*", "next": "return" }],
"@typescript-eslint/explicit-module-boundary-types": "off",
"eslint-comments/disable-enable-pair": [
"error",
{
"allowWholeFile": true
}
],
"eslint-comments/no-unused-disable": "warn",
"jest/valid-title": "off",
}
}
module.exports = {
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": __dirname,
"project": "./tsconfig.json"
},
"env": {
"es6": true,
"jest": true
},
"ignorePatterns": [
"node_modules",
"build",
"coverage",
".eslintrc.js",
"jest.config.js"
],
"plugins": [
"import",
"eslint-comments",
"@typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:jest/recommended",
"plugin:jest/style",
"prettier"
],
"globals": {
"BigInt": true,
"console": true,
"WebAssembly": true
},
"rules": {
"padding-line-between-statements": ["error", { "blankLine": "always", "prev": "*", "next": "return" }],
"@typescript-eslint/explicit-module-boundary-types": "off",
"eslint-comments/disable-enable-pair": [
"error",
{
"allowWholeFile": true
}
],
"import/order": [
"error",
{ "newlines-between": "always", "alphabetize": false }
],
"sort-imports": [
"error",
{
"memberSyntaxSortOrder": ["none", "all", "single", "multiple"],
}
],
"eslint-comments/no-unused-disable": "warn",
"jest/valid-title": "off",
}
} |
trying to help figure this out. ive traced the error to:
[".ts", ".tsx"].includes(_) && (m.eslint.parser = m.eslint.parser || require.resolve("@typescript-eslint/parser")); cant find this anywhere in your source code though. so it must be something vscode injects automatically? update: tried installing |
@the-vampiire That code is from 'prettier-eslint'. It gets bundled during the build. I'll take a look later today hopefully. |
Great thank you for this awesome extension. If there's anything I can do to help please just tag me. |
I get |
This issue is stale because it has been open for 14 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
🚀 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 Also I didn't have the Original comment: Getting this error with the latest pre-release version (v5.0.1):
The following didn't work:
|
@ownchoice Written this way, mine doesn't work. |
@chy9610 More than likely something else is wrong with your ESLint config. Try running |
@idahogurl Thank you. Let me try. |
@idahogurl Succeed, Very Nice. (^o^)/~ |
Describe the bug
I have a
v4.0.0-beta
version of extension, and on formatting action it shows me the error:But the '@typescript-eslint/parser' package is installed locally:
To Reproduce
Steps to reproduce the behavior:
v4.0.0-beta
version of the extension.yarn add @typescript-eslint/parser@^5.0.1
Versions (please complete the following information):
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
The text was updated successfully, but these errors were encountered: