'clear' 在 npm 中不是内部或外部命令,也不是可运行的程序或批处理文件

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

每当我试图清除节点中的命令行时,它都会反映以下错误

'clear' is not recognized as an internal or external command,
operable program or batch file.

虽然尝试通过commond“npm run start”访问index.js,但它显示上述错误,你能请任何人帮助解决这个问题吗?

我是 NodeJS 的基础学习者,尝试在 VS 代码中运行基本的 javascript 文件,但我无法使用命令 -exec clear 清除命令行

下面是 package.json 中的脚本命令行

"scripts": {
  "start": "nodemon --exec 'clear && node' ./src/index.js -q"
}
javascript node.js nodemon
2个回答
1
投票

TL;博士; https://github.com/remy/nodemon/blob/master/faq.md#how-to-clear-the-console-on-restart

我假设你的意思是清除终端屏幕的

clear
命令,在windows下被称为
cls
。 该命令是您正在使用的 shell(zsh、bash 等)的内部命令。 nodemon 直接运行您的命令,而不是在 shell 内部运行,但即使它可以清除也没有什么可清除的,因为它无论如何都会创建一个已经清除的新 shell 进程。

查看 nodemon 文档,有一个 FAQ 条目可以满足您的需求:

在您的 nodemon.json(或您的 package.json)中,您可以包含以下事件处理程序以在 nodemon 启动时始终清除控制台:

{
 "events": {
   "start": "cls || clear"
 }
}

~https://github.com/remy/nodemon/blob/master/faq.md#how-to-clear-the-console-on-restart


0
投票

安装 ncurses 足以解决我的问题:

yum install ncurses
© www.soinside.com 2019 - 2024. All rights reserved.