Can Node.js invoke Chrome?

后端 未结 8 1417
长发绾君心
长发绾君心 2021-02-04 09:54

Is it possible for Node.js running on a desktop to spawn a Chrome Browser window? I would like to start a Chrome Browser providing the window size and location when Node.js rece

8条回答
  •  孤独总比滥情好
    2021-02-04 10:15

    This can be done using open npm package.

    app.listen(PORT, (err) => {
      if (err) console.log(err);
      else open(`http://localhost:${PORT}`, { app: "google chrome" });
    });
    

    We can specify any browser in second parameter with open function.

提交回复
热议问题