adopted-ember-addons / ember-electron

:zap: Build, test, compile and package desktop apps with Ember and Electron
https://ember-electron.js.org/
Other
805 stars 109 forks source link

requireNode does not work #54

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi, first thanks for this module, it helps me a lot! I want to use a Node module (sqlite3) inside my electron/ember application. For testing I created a new ember application with ember-cli 2.3.0 via ember new testapp. Then I ran npm install sqlite3 --save and ember install ember-electron. Now, when I try to include sqlite3 by writing requireNode('sqlite3') I see this error in the JavaScript console of my electron application. Does anyone have any hints?

ember.debug.js:31566 Error: Cannot find module 'testapp/routes/index'
    at Function.Module._resolveFilename (module.js:339)
    at Function.Module._load (module.js:290)
    at Module.require (module.js:367)
    at require (internal/module.js:16)
    at window.require (index.html:65)
    at _extractDefaultExport (resolver.js:346)
    at resolveOther (resolver.js:81)
    at superWrapper (ember.debug.js:22638)
    at exports.default._emberRuntimeSystemObject.default.extend.resolveRoute (ember.debug.js:5779)
    at exports.default._emberRuntimeSystemObject.default.extend.resolve (ember.debug.js:5619)onerrorDefault @ ember.debug.js:31566exports.default.trigger @ ember.debug.js:53631(anonymous function) @ ember.debug.js:54880Queue.invoke @ ember.debug.js:327Queue.flush @ ember.debug.js:391DeferredActionQueues.flush @ ember.debug.js:192Backburner.end @ ember.debug.js:570Backburner.run @ ember.debug.js:692Backburner.join @ ember.debug.js:712run.join @ ember.debug.js:20712(anonymous function) @ ember.debug.js:20775fire @ jquery.js:3099self.fireWith @ jquery.js:3211jQuery.extend.ready @ jquery.js:3417completed @ jquery.js:3433
ghost commented 8 years ago

Edit: It seems to work except for the sqlite3 module. For some reason the application wants the file node_modules/sqlite3/lib/binding/electron-v0.37-linux-x64/node_sqlite3.node but only node_modules/sqlite3/lib/binding/npm-something/node_sqlite3.node exists. It actually is not "npm-something" but I renamed it and can not remember the correct name.

felixrieseberg commented 8 years ago

Hey @raafael911, sqlite is a native component and needs to be recompiled to work with Electron. You can find more information and detailed instructions on how to recompile your extensions here: https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md

No worries, it's pretty easy 👍

ghost commented 8 years ago

Thanks for the quick answer!