5

我如何(递归地)使用 NPM 更新所有依赖项?

我通常的方法(使用npm-check-updates)是这样的:

ncu -u                   # updates my package.json to contain the newest versions of my dependencies
npm install              # installs what ncu has written to package.json
npm update --depth 99999 # recursively updates packages to the newest version within the specified range

但是,这不起作用,并且经常使依赖项处于npm audit抱怨子依赖项的状态。(或者,更糟糕的是,npm update --depth 99999有时会挂起。)

运行npm audit fix会更新更多的包,但只是为了修复安全漏洞。

我发现的唯一真正的解决方案是:

rm -rf package-lock.json node_modules # remove any trace of the old packages
npm install                           # start fresh

…但这不可能是正确的解决方案,对吧?正确的?

我很惊讶我不得不在这里问这个问题,但是阅读文档并在互联网上搜索了一段时间只得到了结果npm update --depth 99999npm-check-updates包,它们并不能完全完成这项工作。

4

0 回答 0