我读到这个:How do I override nested NPM dependency versions?
不幸的是,它不能解决我的问题。
我正在尝试将包从使用特定依赖项更改为使用该依赖项的另一个版本。
它是否内置在包中,它应该使用哪个版本的依赖项,或者是否可以更改它?
具体来说,我正在尝试更改 css-loader
对 cssnano@3.10.0
的默认依赖(最新)改为依赖 cssnano@4.0.0-rc.2
(下一个)。
从上面链接的第二个答案中,用户trickpatty 指出:
this will be removed anytime you run npm i instead of editing your package-lock.json and adding the child dependency to "dependencies" there, add the child dependency to your package.json "dependencies" section
其中
cssnano@4.0.0-rc.2
package.json 的 devDependencies 对 css-loader
没有任何作用.它仍然使用 cssnano
的另一个(默认)版本。 .
最佳答案
有几种选择:
package.json
来实现它。 : "resolutions": {
"package-a": "2.0.0"
}
编辑:找到另一种选择:https://www.npmjs.com/package/npm-force-resolutions
关于javascript - 覆盖 npm 包依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50474126/