Jump to content
GreenSock

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

SyntaxError: Unexpected token 'export' on NPM import

Recommended Posts

Hi,

 

I'm a member of the GreenSock club and successfully downloaded and installed GSAP 3.0 and bonus plugins using the gsap-bonus.tgz method with YARN. I'm now trying to import the DrawSVGPLugin but it's throwing errors in my Terminal and then also in my browser.

 

This is the setup in my main app index.js:

 

import 'dom4'
import 'svgxuse'
import domready from 'domready'
import { gsap } from 'gsap'
import { DrawSVGPlugin } from 'gsap/DrawSVGPlugin.js'
import Swup from 'swup'
import SwupBodyClassPlugin from '@swup/body-class-plugin'
import SwupJsPlugin from '@swup/js-plugin'
import GlobalHeader from '../global-header'
import ProjectGallery from '../our-work/project-gallery'
import Contact from '../contact'
import GlobalFooter from '../global-footer'
import ScrollBtn from '../scroll-btn'
import InView from '../in-view'

gsap.registerPlugin(DrawSVGPlugin)

This is the error that is showing in my Terminal:

 

ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: keyword (var) [./~/gsap/DrawSVGPlugin.js:208,0]

And this is the console error in my browser (Chrome):

Uncaught SyntaxError: Unexpected token 'export'

I can see the plugin inside the node_modules/gsap folder.

 

I'm also running webpack@1.15.0

 

Any help would be greatly appreciated.

 

Thanks,

Dayne

Share this post


Link to post
Share on other sites

It definitely sounds like an issue in your build system. Perhaps your setup doesn't understand ES Modules? If that's the case, then just import the ES5 UMD files from the /dist/ directory like:

import { gsap } from 'gsap/dist/gsap.js'
import { DrawSVGPlugin } from 'gsap/dist/DrawSVGPlugin.js'

Does that help? 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks so much for getting back to me. That method worked perfectly.

Share this post


Link to post
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.

×