Open fkopp81 opened 6 years ago
@fkopp81 Hey. Thanks for filing this.
So I'm not sure what the exact failure is here because I don't know what electron does for a stack trace. repl.repl.history[0]
appears to be undefined.
If you are able to link to a project with setup instructions, so that I can reproduce, I can give it a try. Mainly, I'm curious if this would be the case for any electron app (meaning I could reproduce from basic instructions).
Alternatively, if you're interested in debugging this yourself, could you console.info repl.repl and repl.repl.history in the line above line 119?
That said, it's possible it will just be blank though. If the repl isn't actually in use as in a normal node runtime, then the __LINE__ analog will need to come from somewhere else (for browsers it looks at the loaded file whereas in a node shell, it looks at the repl history).
Maybe a better option would be to edit this function:
function getExpression(){
if(environment()==="file"){
const line = createLineFromErrorObject();
const content = fs.readFileSync(line.fileName, "utf8");
return parseLine(content, line.number-1);
} else{
return getWishFromNodeHistory();
};
};
Remove the else clause from that all together, and see if it works. If it does, then the environment
function should find a way to distinguish between browsers, electron, and node.
Again, thanks for reporting. I'll leave this open, but probably won't make this change myself in the short term at least. If you have any other ideas or want to make a patch, let me know.
Hi,
I have found wish as well via "Refactoring JS". I have seen wish is having trouble under Windows, but while I am using that OS I haven't seen this specific error in other issues:
ReferenceError: repl is not defined
I am trying to use wish together with Spectron and Jest to test an electron app.
From what I can see, "repl" is not defined in an electron context, but it can be require'd by adding:
const repl = require('repl');
However, that leads to another error: