我应该自己解决npm对等项依赖吗?

时间:2018-07-31 16:34:55

标签: npm dependencies peer-dependencies

我似乎已经为此陷入了困境。虽然我以webpack为例,但我正在寻找并非特定于webpack的答案。理想情况下,我想解决这些问题,但我是否还要打扰?

我有一个应用程序,其依赖项具有不同版本的webpack的对等依赖项。当我运行npm install时,这就是我看到的(为清楚起见添加了新行):

npm WARN babel-loader@7.1.2 requires a peer of webpack@2 || 3 but none is installed. You must install peer dependencies yourself.

npm WARN extract-text-webpack-plugin@3.0.2 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.

npm WARN file-loader@1.1.5 requires a peer of webpack@^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN html-webpack-plugin@2.29.0 requires a peer of webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3 but none is installed. You must install peer dependencies yourself.

npm WARN css-loader@1.0.0 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN schema-utils@0.4.5 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN sw-precache-webpack-plugin@0.11.4 requires a peer of webpack@^1 ||^2 || ^2.1.0-beta || ^2.2.0-beta || ^3 but none is installed. You must install peer dependencies yourself.

npm WARN uglifyjs-webpack-plugin@0.4.6 requires a peer of webpack@^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 ||^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN webpack-dev-server@2.9.4 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN webpack-manifest-plugin@1.3.2 requires a peer of webpack@1 || 2 ||3 but none is installed. You must install peer dependencies yourself.

我尝试安装所有各种版本,但不确定如何安装。在我的package.json中,webpack的条目一直保持更新到最新安装的状态。当我点击webpack@3.12.0时,依赖项的数量下降到:

npm WARN react-google-maps@9.4.5 requires a peer of @types/googlemaps@^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN react-google-maps@9.4.5 requires a peer of @types/markerclustererplus@^2.1.29 but none is installed. You must install peer dependencies yourself.

npm WARN react-google-maps@9.4.5 requires a peer of @types/react@^15.0.0 ||^16.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN css-loader@1.0.0 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN schema-utils@0.4.5 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

因此,似乎3.12.0满足了我大多数依赖的需求,但是仍然有些麻烦。 gh。

我尝试将"webpack": "^3.0.0 || ^3.0.0 || ^4.0.0"之类的东西放入我的package.json中,但实际上并没有做任何事情。也许我需要全部添加?


我在这里查看了许多答案,但是其中许多答案都是Angular特有的,或者只是说“升级到npm> = 3”。理想情况下,我正在寻找一种方法来在所有依赖项需要另一个依赖项的不同版本的任何情况下消除这些警告。

这个答案似乎非常接近:https://stackoverflow.com/a/22004559/2800116

我尝试npm install --production,但无济于事。

这里有许多答案询问如何解决此问题,但尚未回答: npm started requestion manual install of peer dependencies

我的问题是,我什至不愿意解决这些问题?这不会使应用程序中断或发生任何事情,但是看到这些确实很烦人。我担心这会造成“哭狼的男孩”的情况,在这种情况下,我会将它们视为噪音,而错过可能很重要的事情。 有时甚至添加其中一个对等项也会增加更多未满足的对等项依赖。真可悲!

0 个答案:

没有答案