EDIT2:现在可以了。必须删除所有本地 eslint 软件包。一切都好!
编辑:好的,安装特定版本后,它提示(^1.16.0)它现在再次在命令行中工作。但遗憾的是,这对 Sublime 内部并没有帮助。这里是否有任何设置可能是错误的?
我之前可以正常工作,但在错误地再次安装相同的软件包后,它就崩溃了。最终我试图让 ESLINT 与 Sublime 一起工作。我认为 Sublime 中的所有内容都是正确的,因为我没有更改其中的任何内容。只是 Eslint 不再工作,如“eslint app.jsx”等所示(见下文)。
我收到了 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 package ,他们在安装前声明了一些附加信息。
首先删除所有已安装的软件包,应如下所示:
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@^#.#.#
关于node.js - 安装 Eslint 和插件时未满足的对等依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39911466/