簡體   English   中英

未滿足的對等依賴性安裝Eslint和插件

[英]Unmet peer dependencies installing Eslint and plugins

EDIT2:現在可以了。 必須刪除所有本地eslint軟件包。 一切都很好!

編輯:好的,安裝特定版本后,它正在抱怨(^ 1.16.0),現在它可以再次在命令行中運行。 但這可惜對Sublime毫無幫助。 這里是否有任何可能錯誤的設置?

我之前曾做過這項工作,但再次錯誤地安裝了相同的軟件包后,它壞了。 最終,我試圖讓ESLINT與Sublime一起工作。 而且我認為Sublime中的所有內容都是正確的,因為我在那里沒有進行任何更改。 只是'Eslint app.jsx'等顯示的Eslint不再起作用(請參見下文)。

我在eslint-plugin-import上收到未滿足對等項依賴關系的錯誤。

aa:myResolutions Andreas$ sudo npm install -g eslint eslint-plugin-import

Password:

/usr/local/bin/eslint -> /usr/local/lib/node_modules/eslint/bin/eslint.js

/usr/local/lib

├── eslint@3.7.1 

└── eslint-plugin-import@2.0.0 


aa:myResolutions Andreas$ sudo npm install -g eslint eslint-plugin-import 
eslint-config-airbnb eslint-plugin-react eslint-plugin-jsx-a11y

/usr/local/bin/eslint -> /usr/local/lib/node_modules/eslint/bin/eslint.js

/usr/local/lib

├── eslint@3.7.1 

├─┬ eslint-config-airbnb@12.0.0 

│ └── UNMET PEER DEPENDENCY eslint-plugin-import@^1.16.0

├── UNMET PEER DEPENDENCY eslint-plugin-import@2.0.0

├── eslint-plugin-jsx-a11y@2.2.2 

└── eslint-plugin-react@6.3.0 


npm WARN eslint-config-airbnb@12.0.0 requires a peer of eslint-plugin-
import@^1.16.0 but none was installed.

npm WARN eslint-config-airbnb-base@8.0.0 requires a peer of eslint-plugin-
import@^1.16.0 but none was installed.

aa:myResolutions Andreas$ eslint App.jsx 


Oops! Something went wrong! :(


ESLint couldn't find the plugin "eslint-plugin-import". This can happen for a 
couple different reasons:


1. If ESLint is installed globally, then make sure eslint-plugin-import is 
also installed globally. A globally-installed ESLint cannot find a locally-
installed plugin.


2. If ESLint is installed locally, then it's likely that the plugin isn't 
installed correctly. Try reinstalling by running the following:

npm i eslint-plugin-import@latest --save-dev

我不明白 我首先安裝了它。 但是然后它不再安裝了嗎? 還是至少其他軟件包找不到它?

超過一天的時間我一直在為此撓頭。 所有插件都已在全球范圍內安裝,因此這不應該成為問題,並且在其崩潰之前也是如此。 而且我已經完全重新安裝了node / npm,但似乎無濟於事。

任何人都知道如何解決這個問題?

請注意,在AirBnB config軟件包上 ,它們在安裝前說明了一些其他信息。

首先刪除所有已安裝的軟件包,應為以下內容:

npm uninstall eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-import

接下來,終端運行:

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

這將產生正確的依賴關系,例如:

npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.#

在這里檢查此答案:

npm i -g eslint-config-airbnb-standard
eslint -v

卸載eslint-plugin-importeslint-plugin-jsx-a11yeslint-plugin-jsx-a11yeslint-plugin-react ,您可以安裝eslint-config-airbnb及其對等項依賴項:

對於npm 5+:

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

對於npm <5:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM