All NodeJS child processes are all numbers

I am writing several node.js scripts to start a child process. The code snippet is given below.

var spawn = require('child_process').spawn; var child = spawn ('node', ['script.js']) child.stdout.on('data', function (data) { logger.verbose('tail output: ' + JSON.stringify(data)); } ); child.stderr.on('data', function (data) { logger.error('err data: ' + data); } ); 

Script works well, except that the child process stdout and stderr only prints numeric outputs:

Output Example:

  108,34,44,34,105,110,99,114,101,97,109,101,110,116,97,108,95,112,111,108,108,105 

How to convert these numeric values ​​to a readable string?

Thanks.

+7
stdout child-process
source share
1 answer

data is an array buffer. Call its toString method JSON.stringify(data.toString('utf8'))

+5
source share

All Articles