rin*_*ahn 6 node.js eslint vue.js eslint-plugin-vue
我想使用 linter elint-plugin-vue作为全局node_modules安装,因为我经常使用 Docker,并且我的存储库根目录下可能没有文件夹。
\n之前,我已经像这样安装了 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! :(\n\nESLint: 7.23.0\n\nESLint couldn't find the plugin "eslint-plugin-vue".\n\n(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "/home/user".)\n\nIt's likely that the plugin isn't installed correctly. Try reinstalling by running the following:\n\n npm install eslint-plugin-vue@latest --save-dev\n\nThe plugin "eslint-plugin-vue" was referenced from the config file in "PersonalConfig".\n\nIf you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.\nRun Code Online (Sandbox Code Playgroud)\nls -la /usr/lib/node_modules/ | grep lint显示:
drwxr-xr-x 7 root root 4096 30. M\xc3\xa4r 18:56 eslint\ndrwxr-xr-x 4 root root 4096 30. M\xc3\xa4r 18:56 eslint-plugin-vue\ndrwxr-xr-x 8 root root 4096 19. M\xc3\xa4r 23:09 jsonlint\ndrwxr-xr-x 3 root root 4096 30. M\xc3\xa4r 21:43 vue-eslint-parser\nRun Code Online (Sandbox Code Playgroud)\n~/.eslintrc:
{\n "extends": [\n "eslint:recommended",\n "plugin:vue/vue3-recommended"\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n"plugin:vue/vue3-recommended"我一放进去就弹出上面的错误~/.eslintrc。
\n有办法让它工作吗?如果我正在使用的存储库本地没有,那么将其作为后备会很棒node_modules。
您可以使用该--resolve-plugins-relative-to标志来更改解析插件的目录。
例如,在你的情况下:
eslint . --resolve-plugins-relative-to=/usr/lib/
Run Code Online (Sandbox Code Playgroud)
或者您可以尝试动态获取路径
# Yarn
eslint . --resolve-plugins-relative-to=$(yarn global dir)
# npm
eslint . --resolve-plugins-relative-to=$(npm root -g)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2271 次 |
| 最近记录: |