马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
1. ESLint couldn’t find the plugin “@typescript-eslint/eslint-plugin”.
- Oops! Something went wrong! :(
- ESLint: 7.32.0
- ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".
- (The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/Users/tal/Documents/web/my-vue3-project".)
- It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
- npm install @typescript-eslint/eslint-plugin@latest --save-dev
- The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "BaseConfig".
- If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
复制代码 这个错误表明 ESLint 没有找到 @typescript-eslint/eslint-plugin 插件,通常是由于插件没有精确安装或安装位置不精确。
- npm install --save-dev @typescript-eslint/eslint-plugin
复制代码 2. npm ERR! ERESOLVE unable to resolve dependency tree
- npm ERR! code ERESOLVE
- npm ERR! ERESOLVE unable to resolve dependency tree
- npm ERR!
- npm ERR! While resolving: my-vue3-project@0.1.0
- npm ERR! Found: eslint@7.32.0
- npm ERR! node_modules/eslint
- npm ERR! dev eslint@"^7.32.0" from the root project
- npm ERR!
- npm ERR! Could not resolve dependency:
- npm ERR! peer eslint@"^8.57.0 || ^9.0.0" from @typescript-eslint/parser@8.2.0
- npm ERR! node_modules/@typescript-eslint/parser
- npm ERR! peer @typescript-eslint/parser@"^8.0.0 || ^8.0.0-alpha.0" from @typescript-eslint/eslint-plugin@8.2.0
- npm ERR! node_modules/@typescript-eslint/eslint-plugin
- npm ERR! dev @typescript-eslint/eslint-plugin@"*" from the root project
- npm ERR!
- npm ERR! Fix the upstream dependency conflict, or retry
- npm ERR! this command with --force or --legacy-peer-deps
- npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
- npm ERR!
- npm ERR!
- npm ERR! For a full report see:
复制代码 由于依靠冲突导致 npm 无法精确剖析依靠树。我们添加使用 --legacy-peer-deps 参数便可以解决这个问题
- npm install --save-dev @typescript-eslint/eslint-plugin
- --legacy-peer-deps
复制代码 3. TypeError: Failed to load plugin ‘@typescript-eslint’ declared in ‘.eslintrc.js’: Class extends value undefined is not a constructor or null
这个问题大概与依靠之间的不兼容有关,特别是由于 ESLint 版本和 @typescript-eslint 相关库之间的冲突。
解决方法:
- npm install --save-dev eslint@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest --legacy-peer-deps
复制代码 4. Invalid option ‘–ext’ - perhaps you meant ‘-c’?
- npm run lint
- > my-vue3-project@0.1.0 lint
- > eslint --ext .js,.mjs,.cjs,.ts,.vue
- Invalid option '--ext' - perhaps you meant '-c'?
- You're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details.
复制代码 出现这个,就代表在使用新的 eslint.config.js 设置格式时,某些命令行选项(例如 --ext)已经被弃用或不再必要,但是我的文件却是是.eslintrc.js。
检查 ESLint 版本: 确保你的 ESLint 版本支持 --ext 选项。
ESLint 8.x 版本仍旧支持 .eslintrc.js 和 --ext 参数。
重新执行install:
- npm install eslint@8.39.0 eslint-plugin-vue@9.11.0 --save-dev
复制代码 此时,假如你想继续使用 .eslintrc.js,那么以下命令是有用的:
- npx eslint .
- --ext .js,.mjs,.cjs,.ts,.vue
复制代码 5. eslint 版本不一致
假如你是新项目,那么按照上面的设置来,很少出现问题。但是假如你是在老项目上重新加eslint,我的发起是非必要不加。
但是假如必要加的话,发起你先完成“执行Eslint检查”,然后触发npm run lint,看下有哪些文件、代码出现问题。而且你大概刚出现以下问题:
- [plugin:vite-plugin-eslint] Failed to load plugin '@typescript-eslint' declared in '.eslintrc.js': Class extends value undefined is not a constructor or null
复制代码 有时间,@typescript-eslint 插件的版本较旧大概与较新的 ESLint 版本不兼容。以下是解决此问题的一些步骤:
1、更新 @typescript-eslint 插件。实验将 @typescript-eslint 插件更新到最新版本。使用以下命令更新:
- npm install @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest --save-dev
复制代码
- 确保 vite-plugin-eslint 插件是最新的。
- npm install vite-plugin-eslint@latest --save-dev
复制代码 3、清除缓存并重新安装依靠。删除 node_modules 和 package-lock.json,然后重新安装所有依靠:
- rm -rf node_modules package-lock.json
- npm install
复制代码
- 手动运行 ESLint 检查。确保 ESLint 本身可以正常运行。在项目目录中,使用以下命令运行 ESLint:
- npx eslint src --ext .js,.ts,.vue
复制代码 假如以上步骤没有解决问题,可以参考 ESLint、@typescript-eslint 和 vite-plugin-eslint 的官方文档和 GitHub 问题跟踪器,看看是否有类似问题的解决方案。
6. Invalid option ‘–ext’ - perhaps you meant ‘-c’?You’re using eslint.config.js, some command line flags are no longer available.
- > eslint .
- --ext .js,.mjs,.cjs,.ts,.vue
- Invalid option '--ext' - perhaps you meant '-c'?
- You're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details.
复制代码 在使用 eslint.config.mjs 设置文件时,ESLint 的命令行选项有所不同。--ext 选项在使用新的 eslint.config.* 文件时不再可用,由于文件扩展名可以直接在设置文件中指定。
已经在 eslint.config.mjs 文件中指定了匹配模式为 **/*.{js,mjs,cjs,ts,vue},这会告诉 ESLint 自动处置惩罚这些扩展名的文件,因此无需在命令行中指定 --ext。
使用 eslint 命令直接运行:
直接使用一下命令:
假如您必要进一步自界说检查的目录或文件,可以在命令行中指定目录或文件路径,而无需使用 --ext 选项。例如:
7. ConfigError: Config (unnamed): Key “rules”: Key “constructor-super”: structuredClone is not defined
- > eslint .
- Oops! Something went wrong! :(ESLint: 9.8.0ConfigError: Config (unnamed): Key "rules": Key "constructor-super": structuredClone is not defined
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |