简体   繁体   中英

Open new console to run another Javascript file

What I'm trying to do is open a new command prompt through Node and run a Javascript file.

For example, I would

node file1.js

And that would open a new console instance, which would instantly run

node file2.js

I have the basic outline and can open a new instance, just not pass any commands/arguments

var child_process = require('child_process');

child_process.execSync('start cmd.exe');

I need help passing command line params, cant find out how though.

var child_process = require('child_process');
child_process.execSync('start node file2.js');

Worked for me. Please make sure node.exe is in your PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM