nodejs无法使用spawn将多个参数传递给脚本

时间:2016-08-04 11:43:10

标签: python node.js

我尝试用spawn启动一个python脚本,没有参数它正在工作:

toExecute="myscript.py";
const ls = spawn('python',toExecute);

ls.stdout.on('data', (data) => {
      ...
    });

但是当我尝试传递其他参数时,它不再起作用了:

const ls = spawn('python',[toExecute, "test"]);

我收到以下错误:

 [red] Uncaught Exception: 4 Aug 13:40:59 - SyntaxError: Unexpected
 token u
     at Object.parse (native)
     at Socket.<anonymous> (/home/....js:29:20)
     at emitOne (events.js:77:13)
     at Socket.emit (events.js:169:7)
     at readableAddChunk (_stream_readable.js:146:16)
     at Socket.Readable.push (_stream_readable.js:110:10)
     at Pipe.onread (net.js:523:20)

0 个答案:

没有答案