Skip to content

Instantly share code, notes, and snippets.

@chowey
chowey / child.js
Created January 18, 2012 03:33
Programmatically get a SyntaxError lineno from Node
var fn = '\n var o={a: "Hello";\n b:"World"};'
var child = require('child_process').spawn(process.execPath, ['-e', fn]);
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
var errLines = data.split('\n');
var infoLine = errLines[1].split(':');
var descLine = errLines[4];