Jump to content

Mazlum Tanrıkulu

Gsap and Angular 9: Unexpected token 'export'

Moderator Tag

Recommended Posts

Hello everyone
I'm getting an error from gsap-core.js when i try to use gsap with angular 9. I have used gsap with angular 7 but now I am using angular 9 and getting this error: Screenshot_1.png.2660c6c4b488873cfbd291f0831d20ec.png


js files and directories:
and using:

what is the problem I didn't understand. How can i solve this problem. please help me.
thnx a lot

Link to comment
Share on other sites

I try to change the path of gsap to 


in angular.json and it is working I suppose

Link to comment
Share on other sites

6 minutes ago, Mazlum Tanrıkulu said:

I try to change the path of gsap to 


in angular.json and it is working I suppose


You're importing gsap twice. Either use the import syntax in every file that uses gsap, or add the script to your angular.json file, but not both.


When using the import syntax, you only need to import gsap though. There is no need to import TweenLite/Max, TimelineLite/Max, or any of the eases.

import { gsap } from "gsap";



Eases can be done with strings.

gsap.to(element, { duration: 2.5, ease: "bounce.out", y: -500 });



And you most certainly don't need jQuery.

import { gsap } from "gsap";

gsap.fromTo(".mobile-screen", {
  marginLeft: "20vw"
}, {
  duration: 0.3,
  marginLeft: "100vw"


👆 animating margins is slow. It would be much better to animate x.  And with angular, you really should be using refs instead selector strings.



  • Like 6
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.