EvolveLabs / electron-plugins

Plugin loader for electron applications.
MIT License
58 stars 11 forks source link

fs dependecy error #5

Open marcio199226 opened 7 years ago

marcio199226 commented 7 years ago

Hi i using the latest version of this plugin. I included plugins part in my package.json of my app But when i launch my app i have this error: Uncaught TypeError: fs.readFile is not a function

Can you help me?

Thanks in advance.

justinmchase commented 7 years ago

Code snippet?

marcio199226 commented 7 years ago

This is from index.js called from electron window.loadUrl:

document.addEventListener('DOMContentLoaded', function () {
    angular.bootstrap(document, ['socialNotifier']);
    var context = { document: document };
    plugins.load(context, function (err, loaded) {
        console.log(err, loaded)
        if(err) return console.log(util.inspect(err))
        console.log('Plugins loaded successfully.')
    });
});

This is the repo of my plugin: https://github.com/marcio199226/social-notifier-linkedin I have registered it in npm with the same name of package. This is my package.json: http://paste.ofcode.org/XBwksN3TGfW85nHtNCMWcG This is my main.js: http://paste.ofcode.org/KnnN3jRSZrWJCAAwJBQUic

I noticed that your package require "fs" but your package.json does not require fs package, im a newbie in electron so maybe im wrong, please let me help beacause i would develop an application that can be extended by plugin funcionality.

marcio199226 commented 7 years ago

i figured out why it does not work. In load function this line: var appDir = path.dirname(process.mainModule.filename) proccess.mainModule.filename in my case isn't a directory path from which the app was launched it return something like this: /usr/local/lib/node_modules/electron/dist/resources/electron.asar/renderer/init.js Instead of: '/home/oskar/Desktop/social-notifier'

My system is ubuntu 15.04 i hope you can fix this issue for future improvements of electron platform.

Furthermore i noticed that when i have updated my app and plugin in npm and i relaunch my app i get this error:

Checking validity. plugin check: [ { name: 'social-notifier-linkedin', current: '1.0.1', desired: '1.0.2', valid: false } ] Plugins are not valid. execPath:/usr/local/lib/node_modules/electron/dist/electron copy appDir: /usr/local/lib/node_modules/electron/dist updateDir: /home/oskar/.local/share/social-notifier/updater/1.4.0 { Error: ENOTDIR: not a directory, stat '/usr/local/lib/node_modules/electron/dist/resources/default_app.asar/default_app.js' at Error (native) errno: -20, code: 'ENOTDIR', syscall: 'stat', path: '/usr/local/lib/node_modules/electron/dist/resources/default_app.asar/default_app.js' } { Error: ENOTDIR: not a directory, stat '/usr/local/lib/node_modules/electron/dist/resources/default_app.asar/default_app.js' at Error (native) errno: -20, code: 'ENOTDIR', syscall: 'stat', path: '/usr/local/lib/node_modules/electron/dist/resources/default_app.asar/default_app.js' } { Error: ENOTDIR: not a directory, stat '/usr/local/lib/node_modules/electron/dist/resources/default_app.asar/default_app.js' at Error (native) errno: -20, code: 'ENOTDIR', syscall: 'stat', path: '/usr/local/lib/node_modules/electron/dist/resources/default_app.asar/default_app.js' }

justinmchase commented 7 years ago

Asar support was never added, though it probably could be. I feel like it should just work though, but I'm not sure.

Also, I see in your main window that you're serving the app up from win.loadURL('http://localhost:8000'), which is also a scenario never supported. Instead I think you should be loading a url which is a file on the file system:

win.loadURL(`file://${__dirname}/index.html`)

Loading it from a web page may be why its confused, it would end up with a strange root module. It may be that that url is just exposed as a config option rather than inferred. I would probably need a zip of your app with a minimal reproduction of the issue to test it out further.

marcio199226 commented 7 years ago

Ok i will provide you some package or something else. Notice that I'm not doing any package of my application i test it only running by: electron . But when i do an update through elup update it works perfectly....