Kitt-AI / snowboy

Future versions with model training module will be maintained through a forked version here: https://github.com/seasalt-ai/snowboy
Other
3.08k stars 997 forks source link

"module not found" on Electron #63

Closed causztic closed 7 years ago

causztic commented 7 years ago

Hi!

I'm currently using the python library and spawning a child process for snowboy in Electron to detect my hotwords, and it works pretty well! I've noticed that you guys recently added the Node library so I wanted to update my code for better flexibility.

While adding the example code

const { Models, Detector } = require("snowboy");

Electron throws an error of

cannot find module /Users/user/node_modules/snowboy/lib/node/binding/Release/electron-v1.4-darwin-x64/snowboy.node'

Any ideas?

evancohen commented 7 years ago

Electron supports native node modules, but because it comes bundled with its own V8 runtime there's some additional complexity. Likely your local version and electron version of v8 are mismatched.

Snowboy uses node-pre-gyp so I suggest using electron-rebuild to rebuild the module. Make sure to use the correct headers when rebuilding.

Looks like you are on macOS so you dont need this, but for anyone else interested: On Linux you'll need the following libraries to build:

sudo apt-get install libmagic-dev libatlas-base-dev
causztic commented 7 years ago

Thanks for the tip!

I've used ./node_modules/.bin/electron-rebuild --pre-gyp-fix and it created the version in the lib folder correctly.

rhclayto commented 7 years ago

Just a quick tip: sudo apt-get install libmagic-dev libatlas-base-dev is for Raspbian, etc. To get the same libraries for Arch Linux:

I had to install file 5.32-1 from the Arch Linux packages & openblas-lapack 0.2.20-1 from the AUR user repository: https://aur.archlinux.org/packages/openblas-lapack/