Eslint:如何使用全局安装的 eslint-plugin-vue

问题描述

我想使用 linter elint-plugin-vue 作为全局安装,因为我经常使用 Docker 并且我可能没有 node_modules 文件夹我的存储库的根目录。
以前,我已经像这样安装了 linter:sudo npm install -g eslint eslint-plugin-vue vue-eslint-parser

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

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 显示

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

{
  "extends": [
    "eslint:recommended","plugin:vue/vue3-recommended"
  ]
}

一旦我将 "plugin:vue/vue3-recommended" 放入 ~/.eslintrc 中,就会弹出上述错误
有没有办法使这项工作?如果我正在使用的存储库在本地没有 node_modules,那么将此作为后备会很棒。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)