Require('child_process') => cannot find Require / child_process + launch .bat

前端 未结 1 1846
野趣味
野趣味 2021-01-28 11:39

It has been 3 days I\'m searching on forums a way to make work my program, and it still doesn’t work…

I\'m working on my first AngularJS project, and I

相关标签:
1条回答
  • 2021-01-28 12:20

    You can't run a child process through a web browser, unless your app is running in a desktop app container such as Electron (which makes Node modules available within its web runtime). It would be horrendously insecure to allow browsers to execute shell scripts - imagine if a pop-up was able to download a .bat and immediately run it on your machine...

    That said, if you want the batch file to run on the server and just be triggered by the client, that's perfectly feasible - just call child_process.spawn() in response to a REST call of some kind.

    0 讨论(0)
提交回复
热议问题