Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Could not load plugin @ typescript-eslint: cannot find module 'eslint-plugin-@typescript-eslint' #287

Closed
baixiaoji opened this issue Jul 17, 2019 · 29 comments

Comments

@baixiaoji
Copy link

baixiaoji commented Jul 17, 2019

I reconfigure my project from tslint to eslint. I can start eslint manually, but the webpack does not start with this error message:

Module build failed (from /path/node_modules/eslint-loader/index.js):
Error: Failed to load plugin @typescript-eslint: Cannot find module 'eslint-plugin-@typescript-eslint'

I'm not sure if this is a major eslint-loader problem.

module.exports = {
  parser: "@typescript-eslint/parser",
  plugins: ["@typescript-eslint"],
  extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended", "plugin:jest/recommended", "prettier", "prettier/@typescript-eslint"],
  rules: {
    "react/prop-types": false
  },
  parserOptions: {
    ecmaVersion: 6,
    project: "./tsconfig.json",
    sourceType: "module"
  },
settings: {
    react: {
      version: "detect"
    },
    linkComponents: [
      {"name": "Link", "linkAttribute": "href"}
    ]
  },
  env: {
    browser: true
  }
};

My .json package

{
    "dependencies": {
        "@emotion/core": "10.0.6",
        "facepaint": "1.2.1",
        "react": "16.7.0",
        "react-dom": "16.7.0",
        "react-redux": "6.0.0",
        "redux": "4.0.1",
        "tslib": "1.9.3"
    },
    "devDependencies": {
        "@types/node": "10.12.21",
        "@types/react": "16.8.1",
        "@types/react-dom": "16.0.11",
        "@types/react-redux": "7.0.1",
        "@typescript-eslint/eslint-plugin": "1.2.0",
        "eslint": "5.13.0",
        "eslint-config-prettier": "4.0.0",
        "eslint-plugin-jest": "22.2.2",
        "eslint-plugin-react": "7.12.4",
        "tsconfig-paths-webpack-plugin": "3.2.0",
        "typescript": "3.2.1"
    }
}

@baixiaoji baixiaoji changed the title Could not load plug-in @ typescript-eslint: cannot find module 'eslint-plugin- @ typescript-eslint' Could not load plugin @ typescript-eslint: cannot find module 'eslint-plugin-@typescript-eslint' Jul 17, 2019
@ricardogobbosouza
Copy link
Collaborator

@baixiaoji I think your configuration is wrong

module.exports = {
  ...
  plugins: ["@typescript-eslint"] // wrong
  plugins: ["@typescript-eslint/eslint-plugin"] // right
  ...
}

@baixiaoji
Copy link
Author

@baixiaoji I think your configuration is wrong

module.exports = {
  ...
  plugins: ["@typescript-eslint"] // wrong
  plugins: ["@typescript-eslint/eslint-plugin"] // right
  ...
}

i change the config, but having a new error

Failed to load plugin @typescript-eslint/eslint-plugin: Cannot find module '@typescript-eslint/eslint-plugin-eslint-plugin'

@baixiaoji
Copy link
Author

@ricardogobbosouza
finally, i find it's eslint plugin error in version 4.19, but I update to the 5.14 it's ok

@mi-mazouz
Copy link

not working with eslint version 6.1.0

@Kevin-coder80
Copy link

not working with eslint version @6.1.0

i reduce the version of eslint from 6.x.x to 5.14, it's worked

@jimmybrawn
Copy link

still problem here with 5.14

@FuzzyAtish
Copy link

not working with eslint version @6.1.0

i reduce the version of eslint from 6.x.x to 5.14, it's worked

Same thing here.
After downgrading eslint from 6.6.0 to 5.14 it started working

@mrmckeb
Copy link

mrmckeb commented Oct 30, 2019

I've just heard reports of this issue with ESLint 6.6.0 in my team, it is fine on ESLint 6.5.1 though.

This may be an ESLint issue.

omerose added a commit to omerose/cypress-support that referenced this issue Nov 4, 2019
Weird bug encountered. Doesn't happen on eslint 5.14.1 version.

Error was: 
```'@typescript-eslint' declared in 'dashboard/.eslintrc.js': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:```

Fix was talked about in this issue:
`webpack-contrib/eslint-loader#287
@Sebastp
Copy link

Sebastp commented Nov 6, 2019

Still, no fix doesn't work when downgrading eslint

@FuzzyAtish
Copy link

Still, no fix doesn't work when downgrading eslint

Have you tried downgrading to version 5.x.x like @seedliu mentioned above
It's working for me with versions 5.14.1 and 5.16 too

@Sebastp
Copy link

Sebastp commented Nov 6, 2019

Still, no fix doesn't work when downgrading eslint

Have you tried downgrading to version 5.x.x like @seedliu mentioned above
It's working for me with versions 5.14.1 and 5.16 too

Yup, 5.14 and 6.5.1 doesn't work for me

@ricardogobbosouza
Copy link
Collaborator

ricardogobbosouza commented Nov 6, 2019

Its works!
Please see the documentation at https://github.com/typescript-eslint/typescript-eslint#how-do-i-configure-my-project-to-use-typescript-eslint

// package.json
{
    "scripts": {
        "dev": "webpack"
    },
    "devDependencies": {
        "@typescript-eslint/eslint-plugin": "^2.6.1",
        "@typescript-eslint/parser": "^2.6.1",
        "eslint": "^6.6.0",
        "eslint-loader": "^3.0.2",
        "typescript": "^3.7.2",
        "webpack": "^4.41.2",
        "webpack-cli": "^3.3.10"
    }
}
// .eslintrc
{
    "parser": "@typescript-eslint/parser",
    "plugins": ["@typescript-eslint"]
}
// webpack.config.js
module.exports = {
    mode: "development",
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'eslint-loader'
            }
        ]
    }
}

@ricardogobbosouza
Copy link
Collaborator

Please, if any error occurs, provide a repository and step by step to reproduce

@FuzzyAtish
Copy link

FuzzyAtish commented Nov 15, 2019

Hello,
Sorry for the follow-up, I'm aware that the issue has been closed, I'd just like to share my experience.
For some reason, I was encountering this error within Visual Studio Code only when my project wasn't in the root folder of the project, i. e. there's a C# project, where the client side is separately included, but it's not the root.
Once I've reopened the project in VS Code as the root location, I didn't encounter the error.
After correctly configuring VS Code, with the eslint.WorkingDirectories setting, everything was working fine

@RahmatAliMalik5
Copy link

RahmatAliMalik5 commented Jan 19, 2020

Error Still there. I am using eslint as global with one .eslintrc.json for all of my projects. I am using @typescript-eslint to lint .ts files.

I have just installed fresh windows.
Installed eslint and @typescript-eslint globally.
Got error of @typescript-eslint not found as described previously here.
Came on this page. Checked the eslint verions, which was 6.8.
Downgraded to 5.14 and working great.

My .eslintrc.json file is as follows:

{
  "env": {"browser": true, "node": true, "es6": true },
  "parser": "@typescript-eslint/parser",
  "extends": ["plugin:@typescript-eslint/recommended", "eslint:recommended"],
  "plugins": ["@typescript-eslint", "prettier"],
  "settings": {
    "import/parsers": {
      "@typescript-eslint/parser": [".ts"],
      "@typescript-eslint": [".ts"]
    },
    "import/resolver": {
      "typescript": {}
    }
  },
  "overrides": [
    {
      // enable the rule specifically for TypeScript files
      "files": ["*.ts", "*.tsx"],
      "rules": {
        "@typescript-eslint/explicit-function-return-type": ["error"]
      }
    }
  ],
 rules: [ 
// lots of rules. Emitted for ease
]
}

@ricardogobbosouza
Copy link
Collaborator

@RahmatAliMalik5
Please provide a repository and step by step to reproduce

@RahmatAliMalik5
Copy link

@ricardogobbosouza
Thanks for your comment. I get error only when I use eslint as global by installing eslint and other packages globally by using npm i -g. I like to use only one .eslintrc.json file for all of my projects. Therefore, I am using global eslint settings in my Visual Studio Code.

The error maybe due to VS Code extension ESLint, I am using to lint automatically (link of extension).

I have tested it several times. Don't know why it comes only when I us latest version globally. It never comes when I use local .eslintrc.json or previous version 5.14 for global configuration.

@mkaufmaner
Copy link

mkaufmaner commented Feb 6, 2020

Hello,
Sorry for the follow-up, I'm aware that the issue has been closed, I'd just like to share my experience.
For some reason, I was encountering this error within Visual Studio Code only when my project wasn't in the root folder of the project, i. e. there's a C# project, where the client side is separately included, but it's not the root.
Once I've reopened the project in VS Code as the root location, I didn't encounter the error.
After correctly configuring VS Code, with the eslint.WorkingDirectories setting, everything was working fine

The following worked for me.

{project}.code-workspace

{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"eslint.workingDirectories": [
			{"mode": "auto"}
		]
	}
}

@ricardogobbosouza
Copy link
Collaborator

@RahmatAliMalik5 this is a change in eslint 6.
See https://eslint.org/docs/user-guide/migrating-to-6.0.0#plugins-and-shareable-configs-are-no-longer-affected-by-eslints

@renjithspace
Copy link

Hello,
Sorry for the follow-up, I'm aware that the issue has been closed, I'd just like to share my experience.
For some reason, I was encountering this error within Visual Studio Code only when my project wasn't in the root folder of the project, i. e. there's a C# project, where the client side is separately included, but it's not the root.
Once I've reopened the project in VS Code as the root location, I didn't encounter the error.
After correctly configuring VS Code, with the eslint.WorkingDirectories setting, everything was working fine

This is the issue I'd been facing. I moved the source code to root of the project directory and it got fixed. @FuzzyAtish Thanks! ✌️

@zcq1933
Copy link

zcq1933 commented Feb 28, 2020

after i downgraded it it work succeed
1,npm uninstall eslint
2, sudo npm install --save-dev -g eslint@5.14
3,eslint --init

1 similar comment
@zcq1933
Copy link

zcq1933 commented Feb 28, 2020

after i downgraded it it work succeed
1,npm uninstall eslint
2, sudo npm install --save-dev -g eslint@5.14
3,eslint --init

@seyfer
Copy link

seyfer commented Apr 1, 2020

if you run eslint from CLI there is a parameter --resolve-plugins-relative-to /path which could help you to point to your project root dir.
In my case, the problem was that we run eslint from the parent directory.

@giacomoalonzi
Copy link

I got the same error without any update, the same codebase as yesterday.
Error: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Cannot find module 'typescript'

I don't know what I have to do actually....

@vsakaria
Copy link

Node version to 12.x done it for me

@jotatoledo
Copy link

Related to typescript-eslint/typescript-eslint#2100

@eeezae
Copy link

eeezae commented Jun 1, 2020

Related to typescript-eslint/typescript-eslint#2100

Error: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Cannot find module 'typescript'

Error still exists, downgrade to version 3.0.0 or update to 3.0.3 alpha not work to me.

@tmhpfnr
Copy link

tmhpfnr commented Jun 16, 2020

What I've found is, that when you run npm ls it says

npm ERR! peer dep missing: typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta, required by tsutils@3.17.1

So once I added the concrete dependency via npm i --save-dev typescript@3.7.0-beta it worked for me (I was using typescript globally before).

Hope that helps.

@samuel2749
Copy link

samuel2749 commented Aug 12, 2020

I had this problem too, I try to upgrade my node.js, and then it is fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests