如何杀死节点JS过程(How to kill process with node js)

2019-09-29 23:42发布

Im running BDD tests that uses IE, chrome and firefox drivers. Sometimes when my tests fails it doesnt kills the drivers so it keeps running. I want to kill all the process with the process name, something like this in windows

taskkill /F /IM chromedriver.exe /T

but with node js or something that will work along in linux and windows machines. If its with some gulp plugin would be great so I can add it as a task.

Answer 1:

您正在寻找类似fkill

工作在MacOS,Linux和Windows操作系统。

用法示例:

const fkill = require('fkill');

fkill(1337).then(() => {
    console.log('Killed process');
});

fkill('Safari');

fkill([1337, 'Safari']);


文章来源: How to kill process with node js