Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import 'node-expat' on Electron boilerplate with webpack #168

Open
vedmant opened this issue Nov 9, 2016 · 4 comments
Open

Can't import 'node-expat' on Electron boilerplate with webpack #168

vedmant opened this issue Nov 9, 2016 · 4 comments

Comments

@vedmant
Copy link

vedmant commented Nov 9, 2016

I use this boilerplate https://github.com/chentsulin/electron-react-boilerplate

Installed node-expat, then when I try to import it with import expat from 'node-expat'; I get following error:

Uncaught Error: Could not locate the bindings file. Tried:
→ project/build/node_expat.node
→ project/build/Debug/node_expat.node
→ project/build/Release/node_expat.node
→ project/out/Debug/node_expat.node
→ project/Debug/node_expat.node
→ project/out/Release/node_expat.node
→ project/Release/node_expat.node
→ project/build/default/node_expat.node
→ project/compiled/6.5.0/darwin/x64/node_expat.node

When I tried to copy node_expat.node file to project/build folder, I get following:

bindings.js:83 Uncaught Error: Module version mismatch. Expected 50, got 48.

@kendallsss
Copy link

Using electron + webpack too.
I get this Error:
path.js:7 Uncaught TypeError: Path must be a string. Received undefined
And error's source is:
var expat = require('bindings')('node_expat')
Webpack give this warnning:
./app/~/bindings/bindings.js
Critical dependencies:
76:22-40 the request of a dependency is an expression
76:43-53 the request of a dependency is an expression

Looks like bindings cause this error, but how can I fix it?

@igl
Copy link

igl commented Feb 7, 2017

You can't bundle native modules with webpack.
Set it as external. v1 v2

@kendallsss
Copy link

Thanks!

@wxplovecc
Copy link

cd ./node_modules/node-expat

and then

node-gyp rebuild --target=1.7.8 --arch=x64  --dist-url=https://atom.io/download/electron

rebuild
see electron doc

if you use webpack to bundle
some posts or use webpack-node-externals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants