SublimeLinter ESLint找不到插件 [英] SublimeLinter ESLint couldn't find the plugin

查看:294
本文介绍了SublimeLinter ESLint找不到插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Sublime Text Editor 3.x中编辑javascript文件时,出现错误:

When editing javascript files in Sublime Text Editor 3.x, I get the error:

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运行皮棉时出现.当我运行eslint命令时,它运行完美.

I tried multiple solutions I found online, including removing global ESLint/moving all ESLint related packages to be global, to altering the SublimeLinter.settings file. The problem only occours when running lint through Sublime. When I run eslint command, it works perfectly.

如果有人知道为什么会发生这种情况,请帮助我!

If anyone has any idea why this is happenning please help me!

谢谢

推荐答案

据我所知,这确实是迁移到ESLint v6的问题. 但是这不是全局安装问题.

As far as I can tell this is indeed a problem with migrating to ESLint v6. But it's not a global installation problem.

现在的问题是ESLint在运行eslint命令的工作目录中查找.如您在您的评论:

The problem is now that ESLint looks in the working directory where the eslint command is run from. As you say in your comment:

它似乎在父文件夹中查找(正如您在错误中看到的那样,它在c:/workspace/flltools中查找,而我的项目在c:/workspace/flltools/modules/scoring

It seems to be looking in a parent folder (as you can see in the error it's looking in c:/workspace/flltools, whereas my project is in c:/workspace/flltools/modules/scoring

因此,编辑器在父目录中而不是package.json文件所在的目录中运行eslint.我猜您的编辑器的项目根目录比package.json文件所在的目录高一级.

So your editor is running eslint in the parent directory rather than in the directory where the package.json file is. I'm guessing your editor has the project root one level higher than where the package.json file is.

看起来确实已经通过github问题#1626在SublimeLinter插件中对其进行了修补:嵌套的本地eslint安装上的工作目录错误(打破eslint @ 6)

It does look like this has now been patched in the SublimeLinter plugin via github issue #1626: Wrong working directory on nested local eslint installs (breaks eslint@6)

请注意,VSCode和Vim都有类似的问题,因此它不是Sublime Text特有的东西,而是ESLint.

Note that I have similar issues with both VSCode and Vim, so it's not a specifically a Sublime Text thing, more just an ESLint thing.

在ESLint v6迁移文档中,其有关插件和可共享的配置不再受ESLint的位置的影响".它表明:

In the ESLint v6 migration doc, it has a section on "Plugins and shareable configs are no longer affected by ESLint’s location". It suggests:

如果使用位于本地项目外部的配置文件(带有--config标志),请考虑将插件安装为该配置文件的依赖项,并将--resolve-plugins-relative-to标志设置为配置文件的位置.

If you use a config file located outside of a local project (with the --config flag), consider installing the plugins as dependencies of that config file, and setting the --resolve-plugins-relative-to flag to the location of the config file.

--resolve-plugins-relative-to将解决此问题,因为您可以指定package.json在其中的位置的路径.

This --resolve-plugins-relative-to will fix the problem in that you can specify the path to where the package.json is inside there.

这篇关于SublimeLinter ESLint找不到插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆