如何撤消 npm 更新? [英] How to undo npm update?

查看:52
本文介绍了如何撤消 npm 更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法撤销命令npm update?我运行了命令,现在我有一堆未满足的依赖项和一些错误.

Is there a way to undo the command npm update? I ran the command and now I have a bunch of unmet dependencies and some errors.

我正在尝试手动重新安装并修复所有错误,但有没有人知道如何从本质上还原 npm 更新?

I'm trying to manually reinstall and fix all the errors but does anyone know how to essentially revert an npm update?

推荐答案

您可以将 package.json 文件恢复到以前的状态(希望您仍然拥有它,或者至少记得您拥有的更改),然后再执行一次 npm update.

You can restore your package.json file to its previous state (hopefully you still have that, or at least remember what you had changed), and then do another npm update.

[更新]

然而,一般来说,这种技术并不能保证你的整个依赖树将恢复到原来的状态(因为依赖树中的 package.json 文件通常松散地指定依赖版本).

However, in general, this technique does not guarantee that your entire dependency tree will be restored to its exact former state (since the package.json files in a dependency tree often loosely specify dependency versions).

如果你需要确保你的包的依赖树可以准确地恢复,你必须使用类似npmshrinkwrap 来锁定"依赖版本(在发布包之前).

If you need to ensure that your package's dependency tree can be restored exactly, you have to use something like npm shrinkwrap to "lock down" the dependency versions (before you publish the package).

这篇关于如何撤消 npm 更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆