我想使用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时,我得到以下信息:
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,那么这将是很好的后盾。
发布于 2021-08-16 20:57:47
您可以使用--resolve-plugins-relative-to标志来更改解析插件的目录。
例如,在您的例子中:
eslint . --resolve-plugins-relative-to=/usr/lib/或者你也可以试着一刀切地找到这条路。
# Yarn
eslint . --resolve-plugins-relative-to=$(yarn global dir)
# npm
eslint . --resolve-plugins-relative-to=$(npm root -g)https://stackoverflow.com/questions/66877732
复制相似问题