首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eslint:如何使用全局安装的

Eslint:如何使用全局安装的
EN

Stack Overflow用户
提问于 2021-03-30 20:03:04
回答 1查看 1.6K关注 0票数 5

我想使用linter elint-plugin-vue作为全局安装,因为我经常使用Docker,而且我的存储库根部可能没有node_modules文件夹。

以前,我安装了链接器,如下所示:sudo npm install -g eslint eslint-plugin-vue vue-eslint-parser

但是,在没有任何/usr/bin/eslint --ext .vue Footer.vue文件夹的情况下运行node_modules时,我得到以下信息:

代码语言:javascript
复制
Oops! Something went wrong! :(

ESLint: 7.23.0

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "/home/user".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in "PersonalConfig".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

ls -la /usr/lib/node_modules/ | grep lint显示:

代码语言:javascript
复制
drwxr-xr-x   7 root root   4096 30. Mär 18:56 eslint
drwxr-xr-x   4 root root   4096 30. Mär 18:56 eslint-plugin-vue
drwxr-xr-x   8 root root   4096 19. Mär 23:09 jsonlint
drwxr-xr-x   3 root root   4096 30. Mär 21:43 vue-eslint-parser

~/.eslintrc

代码语言:javascript
复制
{
  "extends": [
    "eslint:recommended",
    "plugin:vue/vue3-recommended"
  ]
}

当我将"plugin:vue/vue3-recommended"放入~/.eslintrc中时,上面的错误就会弹出。

有办法让这件事成功吗?如果我正在使用的存储库没有本地node_modules,那么这将是很好的后盾。

EN

回答 1

Stack Overflow用户

发布于 2021-08-16 20:57:47

您可以使用--resolve-plugins-relative-to标志来更改解析插件的目录。

例如,在您的例子中:

代码语言:javascript
复制
eslint . --resolve-plugins-relative-to=/usr/lib/

或者你也可以试着一刀切地找到这条路。

代码语言:javascript
复制
# Yarn
eslint . --resolve-plugins-relative-to=$(yarn global dir)

# npm
eslint . --resolve-plugins-relative-to=$(npm root -g)
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66877732

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档