Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

TweenMax into Electron

Recommended Posts

Hi there


I'm having issues getting gsap included properly into an Electron app.

I've a standard browser app (that uses script src, for instance) and now I want to put it within an Electron container without modify too much (I would like to keep it browser compatible with minimal efforts).


I've used some popular tip to get jQuery working on it like this one:

window.$ = window.jQuery = require('./path/to/jquery.js');

But I cannot have TweenMax working using similar tips, I'm getting the error "Uncaught Error: Cannot find module '../TweenLite.js'" while I'm trying to use TweenMax..


Any tips would be very appreciated.




Link to comment
Share on other sites

Hello todotoit and welcome to the GreenSock Forum

Please standby while we look into this. But have you tried to also post your question on Electron git Issues page?


Maybe others in the forum have used Electron and can help answer your question.


Link to comment
Share on other sites

Have you tried using a script tag? 

<script src="./node_modules/gsap/src/uncompressed/TweenMax.js"></script>
  • Like 3
Link to comment
Share on other sites

I know about electron!

You can use script tag instead of that! Since electron is HTML5 + CSS +JS.

Link to comment
Share on other sites

Hi all and thanks for your reply.


After a bit of investigation I can say that TweenMax works fine in Electron.


The problem (and the following mentioned error) happens only when I try to load some plugins, for instance 'DrawSVGPlugin' and 'MorphSVGPlugin'.

"Uncaught Error: Cannot find module '../TweenLite.js'" 

Other plugins seem to work fine. Is it something related to premium only plugins?

Link to comment
Share on other sites

There's nothing related to premium plugins, but we can't see your directory structure. Why don't you just use a script tag? GSAP is global.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
I had this same issue and was able to resolve it by commenting some code out. As 

todotoit mentioned above it seems to be related to using plugins, I was using Draggable. To resolve I made a copy of Draggable and commented out the very last function (export to AMD/RequireJS and CommonJS/Node) - starting at line 2291. you can see in that code there is some requires which i think Electron is confused about the file structure... removing this did the trick for me and was able to run the project finally:


//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
// (function(name) {
// "use strict";
// var getGlobal = function() {
// return (_gsScope.GreenSockGlobals || _gsScope)[name];
// };
// if (typeof(define) === "function" && define.amd) { //AMD
// define(["TweenLite", "CSSPlugin"], getGlobal);
// } else if (typeof(module) !== "undefined" && module.exports) { //node
// require("../TweenLite.js");
// require("../plugins/CSSPlugin.js");
// module.exports = getGlobal();
// }
// }("Draggable"));

Link to comment
Share on other sites

  • 3 months later...

This is still a problem if you use the minified GSAP distribution in electron. The solution is NOT to use script tags. 


The issue is that Electron is also node, and it fakes out the module loader detection code left in these 'minimized' files.

To reproduce this error, make an electron app that loads the following two scripts via script tags:
Yes, you can modify the files to remove the broken loader code.
Another solution is to use the official node distribution.
$ npm install gsap
In my case, I am writing ES6 with babel and webpack, and the transpiled output is running fine in Electron.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.