javascript: eslint-config-airbnb error
I’ve added "extends": "eslint-config-airbnb"
to an empty .eslintrc file and when I run eslint app
I get the following error. If I remove the extends and paste in the node_modules .eslint contents, it works fine. Any ideas? I ran npm install
several times
Error: Cannot find module 'eslint-config-airbnb'
Referenced from: /Users/adam/projects/webpack-boiler/.eslintrc
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at loadConfig (/usr/local/lib/node_modules/eslint/lib/config.js:96:48)
at /usr/local/lib/node_modules/eslint/lib/config.js:123:46
at Array.reduceRight (native)
at loadConfig (/usr/local/lib/node_modules/eslint/lib/config.js:111:36)
at getLocalConfig (/usr/local/lib/node_modules/eslint/lib/config.js:225:23)
at Config.getConfig (/usr/local/lib/node_modules/eslint/lib/config.js:363:22)
webpack-boiler|⇒
{
"name": "meteor-webpack-react",
"version": "0.0.1",
"description": "A port of simple-todos to Webpack/React on the frontend",
"repository": "https://www.github.com/jedwards1211/meteor-webpack-react",
"devDependencies": {
"babel-eslint": "^4.0.5",
"babel-loader": "^5.1.2",
"css-loader": "^0.15.3",
"eslint": "^1.1.0",
"eslint-config-airbnb": "0.0.7",
"eslint-plugin-react": "^3.2.1",
"node-libs-browser": "^0.5.2",
"react-hot-loader": "^1.2.7",
"react-router": "^0.13.3",
"style-loader": "^0.12.3",
"webpack": "^1.10.1",
"webpack-dev-server": "^1.10.1"
},
"dependencies": {
"babel": "^5.6.14",
"babel-core": "^5.6.20",
"classnames": "^2.1.3",
"react": "^0.13.3",
"react-router": "^0.13.3",
"lodash": "^3.10.0"
},
"scripts": {
"dev": "scripts/dev.sh",
"prod": "scripts/prod.sh",
"build": "scripts/build.sh",
"test-built": "scripts/test-built.sh"
},
"author": "",
"license": "MIT"
}
{
"extends": "eslint-config-airbnb"
}
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 11
- Comments: 37 (2 by maintainers)
ah, you’re right, i see it there. However, when you run
eslint app
you’re not running the locally installed version ofeslint
- the local one should only be run under annpm run-script
, which effectively addsnode_modules/.bin
to the PATH for you. Try./node_modules/.bin/eslint app
to confirm?You still have to manually add the package to your
package.json
- trynpm install --save eslint-config-airbnb
npm install -g eslint
(note that --save and --save-dev don’t apply to global installs)Thanks for the fast reply!
I tried
npm install --save eslint-config-airbnb
as well with the same result. I did add it to the package.json, it’s on line 11 under dev dependencies (also tried under reg. deps.) The module is also in node_modules.Any other ideas?
Npm url: https://www.npmjs.com/package/eslint-config-airbnb-base
( export PKG=eslint-config-airbnb-base; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest" )
.eslintrc.json before:
{ "extends": "airbnb" }
after:
{ "extends": "airbnb-base" }
Worked for me…
@gunar If you are referring to using this with syntastic, a trick I learned recently is to just configure
b:syntastic_javascript_eslint_exec
to point to the locally installed version ofeslint
if it exists otherwise fallback to the globally installed:Credit to @gcorne
To run the locally installed version of
eslint
without typing./node_modules/.bin/eslint ...
, you can set up a script inpackage.json
:then just run
npm run lint
. If you installedeslint
locally, it will use that executable otherwise look for a globally installed instance (or anything in your$PATH
variable).Updated: Fixed the vim function
Worked perfect for me 👍
Ooooh, that makes sense! It does run when I use
./node_modules/.bin/eslint app
. However then syntastic breaks and won’t lint.However this lead to me this issue which says that if I need to run eslint globally then I also need to install
eslint-config-airbnb
globally. I did this and now it works great. I can use your solution for my makefile and the global for syntastic (just have to make sure they’re in sync!).Thanks!
{ "extends": "airbnb" }
- this is airbnb config with all react support etc{ "extends": "airbnb-base" }
- this is airbnb config for just JS, and is now deprecatedWhat you need to run is
npx install-peerdeps --dev eslint-config-airbnb
In my case I fixed it by: before:
run this:
it works:
Reason: It seems if libs listed under dev reps, eslint got updated automatically to 7.0 as I explain here later.
Still got this error when using atom with eslint local install. I am using this repo https://github.com/kriasoft/react-starter-kit.
I’d strongly recommend not using global installs (per https://github.com/eslint/eslint/issues/1238#issuecomment-55172447) but as long as it’s working for you, yay! 😃
I was having issues with this on my GatsbyJS site in VS Code.
As per https://www.npmjs.com/package/eslint-config-airbnb I ran
This requires npm 5+
I did that already, same problem npm install -g --save-dev eslint-config-airbnb babel-eslint eslint-plugin-react eslint