我一直在尝试将ESLint与Standard一起使用,但无法使其正常工作。我试过通过eslint --init进行设置,全局卸载eslint并在本地拥有所有软件包,手动npm install --save-dev eslint eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node
手动安装每个软件包,重新安装ESLint扩展,到目前为止什么都没有。我完全可以运行./node_modules/.bin/eslint --fix ...
来修复/检查错误,但是无论如何它都不能与VSCode扩展一起使用。我没有更漂亮,所以也与此无关。
输出:
[Info - 12:33:20 AM] ESLint server is running.
[Info - 12:33:23 AM] ESLint library loaded from: c:\Users\h08FXplsV8\Documents\dev\node\graphql-bootcamp\graphql-prisma\node_modules\eslint\lib\api.js
[Error - 12:33:25 AM]
Failed to load plugin 'import' declared in 'graphql-prisma\.eslintrc » eslint-config-standard': Cannot find module 'eslint-plugin-import'
Require stack:
- C:\Users\h08FXplsV8\Documents\dev\node\graphql-bootcamp\__placeholder__.js
Happened while validating C:\Users\h08FXplsV8\Documents\dev\node\graphql-bootcamp\graphql-prisma\src\resolvers\index.js
This can happen for a couple of reasons:
- The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
- If ESLint is installed globally, then make sure 'eslint-plugin-import' is installed globally as well.
- If ESLint is installed locally, then 'eslint-plugin-import' isn't installed correctly.
.eslintrc:
{
"env": {
"es6": true,
"node": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
}
}
我在SO中也看到了与此问题相关的其他问题,但不幸的是,没有一个解决方案起作用。
答案 0 :(得分:1)
好几个星期我都遇到了同样的问题,最终找到了这个线程并在Github上发表了评论:https://github.com/microsoft/vscode-eslint/issues/696#issuecomment-542592372
我的问题原来与子目录有关。当我使该项目成为唯一一个带有.eslintrc.js文件的打开项目后,我所有的掉毛问题都消失了。
希望这对您有用。
答案 1 :(得分:1)
要修复依赖关系树,请尝试按照 these steps 的确切顺序进行操作: