atom / node-spellchecker

SpellChecker Node Module
http://atom.github.io/node-spellchecker
MIT License
297 stars 106 forks source link

Problems using with electron-webpack-boilerplate #36

Open will-hart opened 8 years ago

will-hart commented 8 years ago

I'm trying to use node-spellchecker with electron-react-boilerplate which uses webpack. My webpack config is virtually unchanged from this repository, only a few more loaders for fonts etc.

If I don't use the node-loader module spellchecker.node is found but throws an error (e.g. the usual "have you installed the correct loader for this file"). However whenever I use the loader webpack bundles correctly however the electron app has an error if I try to require('spellchecker') :

Uncaught Error: Cannot open G:\myapp\node_modules\spellchecker\build\Release\spellchecker.node: 
    Error: The specified module could not be found.
    [object Object]

I can copy and paste the path directly into Windows 10 Explorer and the file opens in Sublime so I know it exists. My webpack output shows that the file was bundled:

[751] ./~/spellchecker/lib/spellchecker.js 2.18 kB {0} [built]
[752] ./~/spellchecker/build/Release/spellchecker.node 258 bytes {0} [not cacheable] [built]

I'm a little overwhelmed by webpack config files but I tried messing about with different externals settings and plugins but can't seem to get it to work. I've also tried using apm rebuild as suggested in #9.

Am I doing something wrong?

will-hart commented 8 years ago

A bit more investigation... if I add the config:

externals: { spellchecker: "commonjs spellchecker" }

Then install electron-rebuild and manually specify the -v and -n flags in my package.json:

"rebuild": "electron-rebuild -v 0.36.8 -n 4.0.0"

Run:

npm install 
npm run rebuild

Then I can import without error.

I think the issue can be closed but is it worth documenting this a bit more, or at least providing some useful links in the readme?

ghost commented 7 years ago

@will-hart totally agree with you here. I'd been developing an app for macOS and Linux for a while using the same boilerplate, and when I began to develop it for Windows I ran into this problem.

After pulling my hair out for hours trying to find what was causing it I figured out it was this module!

My webpack config is already:

externals: [ 'spellchecker' ]

But every time I import spellchecker the electron app crashes. I've tried numerous attempts at using electron-rebuild but I can't figure out how to get it to work for the life of me!