NextJS项目Lint测试报错:ESLint无法唯一识别import插件
NextJS项目ESLint重复插件错误解决方法
错误信息
ESLint: 7.32.0
ESLint couldn't determine the plugin "import" uniquely.
- /Library/...[FOLDER_PATH]..../node_modules/eslint-plugin-import/lib/index.js (loaded in ".eslintrc.json")
- /Library/...[FOLDER_PATH].../node_modules/eslint-config-next/node_modules/eslint-plugin-import/lib/index.js (loaded in ".eslintrc.json » eslint-config-next/core-web-vitals » /Library/...[FOLDER_PATH].../node_modules/eslint-config-next/index.js")
Please remove the "plugins" setting from either config or remove either plugin installation.
该错误是执行yarn upgrade更新依赖后出现的,核心原因是项目同时加载了两份eslint-plugin-import:一份是项目直接安装的,另一份是eslint-config-next自带的依赖,导致ESLint无法唯一识别该插件。
解决步骤
- 检查项目根目录的
.eslintrc.json文件,找到plugins数组,若其中包含"import",直接删除这一项。eslint-config-next的配置已集成该插件的使用,无需手动声明。 - 若上述操作无效,打开
package.json确认是否有直接依赖eslint-plugin-import,执行命令卸载:yarn remove eslint-plugin-import - 最后清理Yarn缓存并重新安装依赖:
yarn cache clean yarn install
内容的提问来源于stack exchange,提问作者Arvind Kushwaha
相关产品推荐
相关产品推荐

