是否可以返回并将您输入的最后一个输入更改为命令提示问卷?

问题描述 投票:0回答:2

如果我不小心输入错字输入命令提示问卷,有没有办法倒退并编辑输入?

例如,当我运行npm init时,我遇到了一堆问题。如果我不小心在package name字段写了一个拼写错误并按回车键,那么问卷就会转移到version:。有没有办法快速回到package name并修复我的拼写错误?

enter image description here

我对终端和npm的体验有限,但我发现你cannot undo a command line。但是,我想知道你是否可以撤消命令提示符的答案,因为这有点不同 - 在完成所有提示之前,命令还没有真正运行。

Sat Apr 27 npm Dashie$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (npm) oops-typo
version: (1.0.0)
shell unix npm terminal command-prompt
2个回答
1
投票

您正在描述的撤消功能必须由您正在使用的cli工具的开发人员实现(在本例中为npm)。

我认为我能提供的最好的方法是在命令行上修复你的错误,而不必打开编辑器并从那里修改package.json文件,就是使用json npm包。

因此,在您的问题中显示的特定情况下,您将继续安装,之后您可以简单地执行:

$ npm i -g json
$ json -I -f package.json -e "this.name='your package name'"

1
投票

您可以在使用init时创建的package.json文件中编辑包名称。

© www.soinside.com 2019 - 2024. All rights reserved.