Issues including scripts


#1

I’m using electron to build a simple editor. So far i’m loving electron, however I’m having one issue I just cant figure out. I’m including a js file however i’m repeatedly getting ‘TypeError: Cannot read property ‘init’ of undefined’ errors. The script works fine in browser, just not in electron. I’ve tried the normal <script src="medium-editor.min.js"></script> but that didn’t work, after a little googling, I found <script>window.$ = window.MediumEditor = require('./medium-editor.min.js');</script> but still no luck. Any ideas?

Thanks,
James.


#2

Have you been following the Electron Quick Start guide?


#3

To some extent yes, the application runs fine, my onload.js runs fine too, it’s purely this additional script, medium-editor.js that does not. What am I missing here? I’ve re-read the quick start and it doesn’t really go into the matter.


#4

Once you’ve loaded the first JS file in the initial loading HTML, you shouldn’t need HTML anymore. You might want to take a look at how Atom does it:


#5

Have you tried the NPM module of the same name?

const MediumEditor = require('medium-editor')
const editor = new MediumEditor('.editable')

#6

That worked perfectly! Thanks!