xmppo / node-expat

libexpat XML SAX parser binding for node.js
https://github.com/xmppo/node-expat
MIT License
384 stars 97 forks source link

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

Open vedmant opened 8 years ago

vedmant commented 8 years ago

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 commented 7 years ago

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 commented 7 years ago

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

kendallsss commented 7 years ago

Thanks!

wxplovecc commented 6 years ago
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