vscode-eslint: Cannot find module 'eslint-config-airbnb' and/or 'eslint-plugin-react'
I’ve been trying to solve this for a couple of days and well… I wouldn’t be asking if I fixed it 😄.
Cannot read config package: eslint-config-airbnb Error: Cannot find module ‘eslint-config-airbnb’ Referenced from: long_path.eslintrc
Cannot read config package: eslint-plugin-react Error: Cannot find module ‘eslint-plugin-react’ Referenced from: long_path.eslintrc
I deleted every package from global (except for webpack and webpack-dev-server).
I ran npm i eslint eslint-plugin-react eslint-config-airbnb babel-eslint -D
and all of them appear in node_modules
and package.json
.
If I run node_modules\.bin\eslint file_name.jsx
the command works just fine, using both the plugin and the config.
packages.json
"devDependencies": {
"babel-core": "^6.6.5",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"chai": "^3.5.0",
"chai-immutable": "^1.5.3",
"eslint": "^2.3.0",
"eslint-config-airbnb": "^6.1.0",
"eslint-plugin-react": "^4.2.1",
"file-loader": "^0.8.5",
"jsdom": "^8.1.0",
"mocha": "^2.4.5",
"path": "^0.12.7",
"react-hot-loader": "^1.3.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
},
.eslintrc
"parser": "babel-eslint",
"plugins": ["react"],
"ecmaFeatures": {
"jsx": true
},
"env": {
"browser": true,
"node": true
},
"extends": "airbnb",
Any tips on debugging this?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 21
- Comments: 35 (15 by maintainers)
Quitting VSCode and opening it again fixed this issue for me.
I was facing the same issue, probably because of eslint installation, eslint was installed globally on my system and all dependencies were installed as dev-dependency. so what I did, simply removed the eslint from global
npm uninstall -g eslint
and install eslint locallynpm i eslint --save-dev
then run this(mac or Linux)
./node_modules/.bin/eslint --init
for windows
.\node_modules\.bin\eslint --init
hope this will fix your problem
You do not need to install everything globally. Check this:
npm i -g eslint-config-airbnb-standard
eslint -v
Here is the guide
It seems vscode-eslint only find node_modules from project root. So if your dir like
project/admin/
, it will not findproject/admin/node_modules/eslint-plugin-react
.@anks333 ESLint in general (the command line version as well) requires that ESLint and all extension are either installed globally or locally. You can’t mix the installation scope.
@merdmann ESlint npm module requires itself and all plugins either being installed locally or globally. Mixing doesn’t work.
Setting up the right dependencies makes this work. However ESLint should detect this and handle this more gracefully. Ending in this wired error is not user friendly