Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

nodejs 怎么启动一个可交互式的命令行工具

如题,我想用nodejs启动htop这个命令,我目前的方式是:

import { spawn } from 'child_process';

const child = spawn('/usr/bin/htop', { shell: true });
process.stdin.pipe(child.stdin);
child.stdout.pipe(process.stdout);

这种方式可以正常显示,但是用户无法与htop交互,htop无法响应键盘事件,我想要的效果和直接在terminal里面输入htop回车的效果一样,nodejs可以实现么?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...