benjeske Posted June 30, 2020 Share Posted June 30, 2020 Hi I'm trying to load gsap into my nextjs project. I've got it nearly completed but I am getting this error from the package: SyntaxError: Unexpected token 'export' /node_modules/gsap/ScrollTrigger.js:534 line 534: export var ScrollTrigger = /*#__PURE__*/function () { Any advice for getting this to work? I've been searching but haven't been able to find any solutions to this problem. Link to comment Share on other sites More sharing options...
elegantseagulls Posted June 30, 2020 Share Posted June 30, 2020 What does your import look like? For nextjs you'll need to import the umd version: import gsap from 'gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; 7 2 Link to comment Share on other sites More sharing options...
benjeske Posted June 30, 2020 Author Share Posted June 30, 2020 3 minutes ago, elegantseagulls said: What does your import look like? For nextjs you'll need to import the umd version: import gsap from 'gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; import ScrollTrigger from 'gsap/ScrollTrigger'; ^ was what I was using This was exactly the problem, thank you!! Link to comment Share on other sites More sharing options...
GreenSock Posted June 30, 2020 Share Posted June 30, 2020 1 hour ago, elegantseagulls said: What does your import look like? For nextjs you'll need to import the umd version: import gsap from 'gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; I would assume that gets the UMD version of ScrollTrigger, but the ES Module of GSAP (the core). Shouldn't it look like this? import { gsap } from 'gsap/dist/gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; 2 Link to comment Share on other sites More sharing options...
benjeske Posted June 30, 2020 Author Share Posted June 30, 2020 6 minutes ago, GreenSock said: I would assume that gets the UMD version of ScrollTrigger, but the ES Module of GSAP (the core). Shouldn't it look like this? import { gsap } from 'gsap/dist/gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; Can confirm, I updated the gsap import as well to the /dist/ directory and it's working. Tested successfully locally and in my production environment. 1 Link to comment Share on other sites More sharing options...
OSUblake Posted July 1, 2020 Share Posted July 1, 2020 5 hours ago, GreenSock said: I would assume that gets the UMD version of ScrollTrigger, but the ES Module of GSAP (the core). Shouldn't it look like this? import { gsap } from 'gsap/dist/gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; I think import { gsap } from 'gsap' gets the umd version in nextjs based on the main field in the package.json. 4 Link to comment Share on other sites More sharing options...
elegantseagulls Posted July 1, 2020 Share Posted July 1, 2020 46 minutes ago, OSUblake said: I think import { gsap } from 'gsap' gets the umd version in nextjs based on the main field in the package.json. It must?... I've never had an issue importing it this way, and we run Next.js with most of our projects. 1 Link to comment Share on other sites More sharing options...
vanja6 Posted June 12, 2021 Share Posted June 12, 2021 Hey guys, I know this was posted long time ago, but I had such a hard time figuring this out and these posts helped me A LOT, so thank you! 2 2 Link to comment Share on other sites More sharing options...
Serhat Düzgün Posted September 21, 2022 Share Posted September 21, 2022 On 6/30/2020 at 8:40 PM, elegantseagulls said: What does your import look like? For nextjs you'll need to import the umd version: import gsap from 'gsap'; import { ScrollTrigger } from "gsap/dist/ScrollTrigger"; Thank you so much. You saved my life! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now