最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin5浏览0评论
➜  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
➜  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
Share Improve this question asked Feb 17, 2017 at 2:32 LiuuilLiuuil 1,5693 gold badges17 silver badges23 bronze badges 2
  • Have you tried... installing the dependency? – Tomalak Commented Feb 17, 2017 at 2:42
  • Does the WARN shows what I have to install exactly the peer ? I thought I already installed the eslint globally that will MEET the requirements. Am I wrong? – Liuuil Commented Feb 17, 2017 at 3:00
Add a ment  | 

5 Answers 5

Reset to default 5

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./package/eslint-config-airbnb-bundle

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

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 mand :

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

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

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 mand :

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

More details here.

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

npx install-peerdeps --dev eslint-config-airbnb

I don't think you should install everything global. Try this:

npm install --save-dev eslint eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-import eslint-plugin-react

Removing node modules (rm -rf node_modules/) and re-running npm install worked for me!!

发布评论

评论列表(0)

  1. 暂无评论