It is possible to get the progress of a spawned process from nodejs?

别等时光非礼了梦想. 提交于 2019-12-21 22:50:03

问题


I'm spawning npm install -g create-react-app from a js script. I want to know if it's possible to get the progress of the installation using spawn.

const npmExecutable = /^win/.test(process.platform) ? "npm.cmd" : "npm";
const npm = spawn(npmExecutable, ["install", "-g", "create-react-app"]);

I have read this question about using:

npm.on("message", data => {
  console.log(`A message: ${data}`);
});

but it does not show anything.

There is a related question, about knowing the progress of a python script, but it does not have any answers.

Does someone of you have tried something like that or know any clue about this?

来源:https://stackoverflow.com/questions/55286601/it-is-possible-to-get-the-progress-of-a-spawned-process-from-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!