Ali*_*cia 1 operating-system node.js
在node.js中是否有一个函数来查找位于其中某处的可执行文件$PATH,类似于whichBash的内置文件?
如果没有,我总是可以尝试解析process.env.PATH并手动搜索每个目录,但我宁愿避免这种情况.
您可能想要查看哪个模块
var which = require('which');
which('ls', function(err, result) {
console.log(result); // prints '/bin/ls' on mac
});
Run Code Online (Sandbox Code Playgroud)