我如何真正地使用 NPM 更新所有依赖项?

fef*_*rei 5 node.js npm npm-update

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

\n\n

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

\n\n
ncu -u                   # updates my package.json to contain the newest versions of my dependencies\nnpm install              # installs what ncu has written to package.json\nnpm update --depth 99999 # recursively updates packages to the newest version within the specified range\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n

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

\n\n

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

\n\n
rm -rf package-lock.json node_modules # remove any trace of the old packages\nnpm install                           # start fresh\n
Run Code Online (Sandbox Code Playgroud)\n\n

\xe2\x80\xa6但这不可能是正确的解决方案,对吧?正确的?

\n\n

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

\n