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

window.requireNode is not a function #25

Closed fredguth closed 8 years ago

fredguth commented 8 years ago

Followed the steps in readme.md. 1) Installed via ember install ember-electron 2) changed locationType to hash 3) filled most (not all) parameters in package.json 4) run ember electron: https://www.evernote.com/l/AZTlIMx3ZN5OJ4pjgtl6QVzdVSS67Lpy6hM

as you can see in the link above, 4 errors appeared.

any idea on what I did wrong?

felixrieseberg commented 8 years ago

It seems to not be finding a bunch of things - what does your dist folder look like?

fredguth commented 8 years ago

https://www.evernote.com/l/AZRQOt44yG1MSY2c1JuinkVatJVOE1SYhfI

and also: https://www.evernote.com/l/AZQa1qjWlG1BAbPqM_YrYVCDopo2V-7-GC8

I just noticed my package.json hasn't the params I filled before.

fredguth commented 8 years ago

Do I need to create a package or using

ember electron

should work?

I tried again and once again didn't work.

You can check my step-by-step here: https://asciinema.org/a/9vwpck0t9ki2621lx0i7usf6z?speed=16

felixrieseberg commented 8 years ago

Hm, interesting - you certainly didn't do anything wrong. Quick check though - if you create a new ember app and run ember install ember-electron right after, does Electron open?

fredguth commented 8 years ago

Yep. It works with ember 2.3 (https://asciinema.org/a/e9494xbxezxet8f8dv3wcxo9y?speed=16) I was using 1.13 :-(

felixrieseberg commented 8 years ago

That's still weird though, given that it should work with Ember Cli 1.13. Can you do me a quick favor and check your index.html? In there, you should find the contents of those two shim files.

fredguth commented 8 years ago

No, there isn't. In the 2.3 test I saw them. I think it is possible that I already had a dist folder here with an index.html. Would the install process overwrite it?

felixrieseberg commented 8 years ago

Dist should be deleted every time you build. I"m fairly certain that there's something wrong with your configuration, but I don't have enough information to help you. If you could zip a repro case, I'm happy to hunt it down!

fredguth commented 8 years ago

Not a version problem. I upgraded my app to 2.3 and still happens. `version: 2.3.0 node: 0.12.10 os: darwin x64``

My dist/index.html

<script>
/* jshint browser: true */
(function (window) {
    if (window && window.process && window.process.type) {
        window.ELECTRON = true;
    }

    window.requireNode = window.require;
    window.moduleNode = window.module;
    window.processNode = window.process;

    delete window.process;
    delete window.require;
    delete window.module;
})(this);

</script>

....
 <script>
/* jshint browser: true */
(function (window) {
    if (!window.ELECTRON) {
        return;
    }

    // Restore Electron variables.
    window.process = window.processNode;

    // Redefine a global `require` function that can satisfy both
    // Node and AMD module systems.
    var requireAMD = window.require;
    var requireNode = window.requireNode;

    if (requireAMD) {
        window.require = function () {
            try {
                return requireAMD.apply(null, arguments);
            } catch (e) {
                return requireNode.apply(null, arguments);
            }
        };
    } else {
        window.require = requireNode;
    }
})(this);

</script>

I will try to create a repo with the error for the hunt!

felixrieseberg commented 8 years ago

Thank you!

fredguth commented 8 years ago

I found the error!

It was totally my bad. Ember-electron is fine.

I found this in my app/index.html

-    <script type="text/javascript">
-      // Electron hack
-      window.module = undefined
-      window.require = undefined
-    </script>```