Steveorevo / node-red-contrib-nbrowser

Provides a virtual web browser (a.k.a. "headless browser") appearing as a node.
34 stars 13 forks source link

requiring electron #2

Closed chuyaguo2014 closed 6 years ago

chuyaguo2014 commented 6 years ago

I was having issue with this line:

electronPath: require('../node_modules/electron'),

and I was getting this error: Cannot find module '../node_modules/electron'

I fixed it by changing the line above to electronPath: require('electron'), and everything worked.


More details about how I set everything up in my environment:

I followed the steps from the node-red tutorial and in my project directory hello-world:

git clone https://github.com/node-red/node-red.git
cd node-red
npm install

at first, I tried going to ~/.node-red and running npm install node-red-contrib-nbrowser, and then going back to my hello-world directory and that's when I got the error the first time.

I then tried running npm install node-red-contrib-nbrowser in my hello-world directory, and I made sure the right modules were available in the node_modules folder under hello_world, but somehow I was still getting the same error.

Eventually, after messing around with the actual code that required electron, I was able to get everything to work. Hope this helps you reproduce the issue on your end. :)

Steveorevo commented 6 years ago

Updated require path to most common location in ce476d833011e563b5237151a50c02dd7a81604b