Jump to content


Cannot find module 'gsap/MorphSVGPlugin'

Recommended Posts

Hello folks 👋,


I have a problem importing gsap plugin. When I try to bundle (with vite) my project I have this error :

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
          triggerUncaughtException(err, true /* fromPromise */);

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/user/Documents/vite-project/node_modules/gsap/MorphSVGPlugin' imported from /Users/user/Documents/vite-project/.vite-ssg-temp/main.mjs
Did you mean to import gsap/MorphSVGPlugin.js?
    at new NodeError (node:internal/errors:371:5)
    at finalizeResolution (node:internal/modules/esm/resolve:416:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {

I am importing gsap package like this in a js file :

import gsap from 'gsap'
import MorphSVGPlugin from 'gsap/MorphSVGPlugin'

of course I have access to the premium plugins (package.json)

  "dependencies": {
    "gsap": "npm:@gsap/shockingly@^3.10.4",

I tried different type of imports (in the js file) without success:

import gsap from 'gsap'
import MorphSVGPlugin from 'gsap/dist/MorphSVGPlugin' // or 'gsap/MorphSVGPlugin.js' or 'gsap/dist/MorphSVGPlugin.js'

even :

import { gsap, MorphSVGPlugin } from 'gsap/all' // or 'gsap/all.js'

Thank you in advance for your response ! 🙂

Link to comment
Share on other sites

This is a vite issue, not a GSAP issue. I've used GSAP + Vite w/o issue more than once without issue. Try disabling SSG and see if it will let you build

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.