chuckfairy / node-webcam

Nodejs Cross Platform Webcam usage
MIT License
193 stars 51 forks source link

__dirname in the require cause problems with PKG #29

Closed gioid closed 5 years ago

gioid commented 5 years ago

If you try to use "pkg" on a project that uses "node-webcam", you will obtain a runtime issue, as described for example in the following issue on pkg repository:

https://github.com/zeit/pkg/issues/426

The problem is caused by the __dirname in the require instructions. If we change the style of requires using relative paths, everything work as expected. For example, we should change an instruction from this:

Factory: require( __dirname + "/src/Factory.js" )

to this:

Factory: require( "./src/Factory.js" )

I can create a pull-request if you want.

chuckfairy commented 5 years ago

thanks, I use to not know how node worked lol.