nightmare icon indicating copy to clipboard operation
nightmare copied to clipboard

Error on simple code

Open aabb11sdio opened this issue 6 years ago • 4 comments

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.

aabb11sdio avatar Nov 26 '18 20:11 aabb11sdio

hello,I run your code. I got the result is string

pizitai avatar Dec 14 '18 09:12 pizitai

it's working fine for me as well.

kobenguyent avatar Dec 17 '18 08:12 kobenguyent

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.

jcugley avatar Mar 12 '19 01:03 jcugley

Thanks jcugley. Wasted a lot of time searching for this solution. Still do not know why it needs the path though

aabellanosa avatar Apr 28 '19 20:04 aabellanosa