埃斯林特安装警告.需要澄清



在下面的教程中,我运行了以下命令来安装 eslint Airbnb 和一些依赖项

$ sudo npm install -g eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y

完成后,我收到了许多警告

npm WARN eslint-plugin-react@7.6.0 requires a peer of eslint@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-import@2.8.0 requires a peer of eslint@2.x - 4.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-configeslint-config-airbnb-airbnb@16.1.0 requires a peer of eslint@^4.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb-base@12.1.0 requires a peer of eslint@^4.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-jsx-a11y@6.0.3 requires a peer of eslint@^3 || ^4 but none is installed. You must install peer dependencies yourself.

好的,所以....我开始认为教程已经过时了,有些东西发生了变化。我错过了什么(如果有的话(?

请指教。

每个节点包都有依赖项,它可以完美运行或已经过测试,因此您会收到警告,因为它们是在包配置中推荐或声明的依赖项。因此警告。建议遵循所需的软件包以避免错误,但大多数情况下,除非您遇到错误,否则您应该很高兴,因为无论存在什么版本,都可以使用。

在您的情况下,请确认您的 package.json 中有eslint,如果没有运行:

npm install eslint --save-dev

所有的警告都是关于peer dependencies的。它们被归类为 WARN 而不是 ERROR ,因为如果您的应用程序代码从未触及这样的依赖关系,那么您会很好。经过全面测试的代码可以确保可以安全地忽略这些警告。

对等依赖关系的出色解释

最新更新