node.js -【node】在node中如何打开当前系统已经安装的某个应用?

【字号: 日期:2022-09-21浏览:28作者:雯心

问题描述

启动项目:

node app.js

在app.js中,如何让node去打开当前系统中已经安装的atom编辑器?

在npm中找到一个包,是可以打开指定浏览器,还是不能打开指定应用程序

//自动打开chrome浏览器var opn=require(’opn’);opn(’http://localhost:8080’, {app: ’chrome’});

问题解答

回答1:

var exec = require(’child_process’).execFile;var fun =function(){ console.log('fun() start'); exec(’atom.exe’, function(err, data) { console.log(err)console.log(data.toString()); }); }fun();

https://nodejs.org/api/child_...

相关文章: