In function PythonShell.prototype.receive(), when data contains only one line, it is saved to lastLine by
var lastLine = lines.pop();
and lines[0] is undifined.
Code line 177
lines[0] = (this._remaining || '') + lines[0];
set lines[0] to be string 'undefined'. This will cause error to be throw at JSON.parse below.
Propose: change line 177 to
if (this._remaining) {
lines[0] = this._remaining + lines[0];
}