nightmare
nightmare copied to clipboard
Error on simple code
Hey!
I keep getting this error: Uncaught (in promise) NodeError: The "file" argument must be of type string. Received type object
When running this code:
nightmare .goto('https://google.com') .evaluate(() => { return document.body.innerHTML }).then(body => { console.log(body) });
I can't seem to find anyone having this problem.
hello,I run your code. I got the result is string
it's working fine for me as well.
I had this exact error.
The issue for me was happening when trying to run nightmare within an electron app. Are you using nightmare inside of electron @aabb11sdio?
I solved the issue by including the electronPath property:
const nightmare = Nightmare({ electronPath: require('./node_modules/electron'), show: true, });
I don't understand why though, so if anyone could help explain why an electronPath is needed, that would be highly appreciated.
Thanks jcugley. Wasted a lot of time searching for this solution. Still do not know why it needs the path though