在 Sublime Text Editor 3.x 中编辑 javascript 文件时,出现错误:
Oops! Something went wrong! :(
ESLint: 6.0.1.
ESLint couldn't find the plugin "eslint-plugin-chai-expect".
(The package "eslint-plugin-chai-expect" was not found when loaded as a Node module from the directory "C:\workspace\flltools".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-chai-expect@latest --save-dev
The plugin "eslint-plugin-chai-expect" was referenced from the config file in "modules\scoring\.eslintrc.yml".
If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
我尝试了在网上找到的多种解决方案,包括删除全局 ESLint/将所有 ESLint 相关包移至全局,以更改SublimeLinter.settings
文件。仅当通过 Sublime 运行 lint 时才会出现此问题。当我跑步时eslint
命令,它完美运行。
如果有人知道为什么会发生这种情况,请帮助我!
谢谢
据我所知,这确实是迁移到 ESLint v6 的问题。But这不是全局安装问题。
现在的问题是 ESLint 在工作目录中查找eslint
命令是从运行的。正如你所说你的评论 https://stackoverflow.com/questions/56879118/sublimelinter-eslint-couldnt-find-the-plugin#comment100326508_56886214:
它似乎正在查找父文件夹(正如您在它正在查找的错误中看到的那样)c:/workspace/flltools
,而我的项目是在c:/workspace/flltools/modules/scoring
因此,您的编辑器在父目录中运行 eslint,而不是在package.json
文件是。我猜您的编辑器的项目根目录比 package.json 文件所在的位置高一级。
看起来这个问题现在已经通过 github 问题 #1626 在 SublimeLinter 插件中进行了修补:嵌套本地 eslint 安装的工作目录错误(破坏 eslint@6) https://github.com/SublimeLinter/SublimeLinter/issues/1626
请注意,我对 VSCode 和 Vim 都有类似的问题,所以它不是专门的 Sublime Text 的东西,更多的是 ESLint 的东西。
在 ESLint v6 迁移文档中,有一个关于“插件和可共享配置不再受 ESLint 位置的影响” https://eslint.org/docs/user-guide/migrating-to-6.0.0#-plugins-and-shareable-configs-are-no-longer-affected-by-eslints-location。它建议:
如果您使用位于本地项目外部的配置文件(带有--config
标志),考虑将插件安装为该配置文件的依赖项,并设置--resolve-plugins-relative-to
标记到配置文件的位置。
This --resolve-plugins-relative-to
将解决该问题,因为您可以指定路径package.json
就在里面。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)