Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install eslint-config-airbnb properly ? `UNMET PEER DEPENDENCY`

➜  beslint git:(master) ✗ eslint -v
    v3.15.0
➜  beslint git:(master) ✗ npm install -g eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-import eslint-plugin-react

/Users/next/.nvm/versions/node/v7.5.0/lib
├── UNMET PEER DEPENDENCY eslint@^3.15.0
├─┬ [email protected]
│ └── UNMET PEER DEPENDENCY eslint@^3.15.0
├── [email protected]
├── [email protected]
└── [email protected]

npm WARN [email protected] requires a peer of eslint@^3.15.0 but none was installed.
npm WARN [email protected] requires a peer of eslint@^3.15.0 but none was installed.
npm WARN [email protected] requires a peer of [email protected] - 3.x but none was installed.
npm WARN [email protected] requires a peer of eslint@^2.10.2 || 3.x but none was installed.
npm WARN [email protected] requires a peer of eslint@^2.0.0 || ^3.0.0 but none was installed.
➜  beslint git:(master) ✗
  • I tired to install globally
  • I use nvm to install node 7.5.0, and installed eslint globally.
  • when I try to install eslint-config-airbnb globally.
  • It said UNMET PEER DEPENDENCY
like image 746
Liuuil Avatar asked Feb 17 '17 02:02

Liuuil


3 Answers

You can install eslint-config-airbnb-bundle. This is an unaltered Airbnb style guide config bundled with ESLint in a single package to solve some inconvenience with the installation (like unmet peer dependency warnings). You can install it globally as well:

npm i -g eslint-config-airbnb-bundle

Airbnb only: https://www.npmjs.com/package/eslint-config-airbnb-bundle

Airbnb + Standard: https://www.npmjs.com/package/eslint-config-airbnb-standard

like image 107
Do Async Avatar answered Oct 24 '22 09:10

Do Async


I faced similar issue but found a solution to this issue. I thought its worth sharing.

To install the correct versions of each package related eslint config , You can run following command :

npm info "eslint-config-airbnb@latest" peerDependencies

You can get exact peer dependency which are listed by running above command:

e.g about outputs ( as of answer's date ) will produce following :

{ eslint: '^3.19.0 || ^4.3.0',
  'eslint-plugin-jsx-a11y': '^5.1.1',
  'eslint-plugin-import': '^2.7.0',
  'eslint-plugin-react': '^7.1.0' 
}

From above output you can exact idea about what dependencies to install for current ( latest build) .

If you want to install all dependencies in one go ( for Linux/OSX users only) Use below command :

(
  export PKG=eslint-config-airbnb;
  npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)

More details here.

like image 45
WitVault Avatar answered Oct 24 '22 10:10

WitVault


From https://www.npmjs.com/package/eslint-config-airbnb

npx install-peerdeps --dev eslint-config-airbnb
like image 41
Jose Alfonso Avatar answered Oct 24 '22 11:10

Jose Alfonso