raana Posted November 11, 2021 Share Posted November 11, 2021 I have a problem that I get this error when I want to output my project. I do not know if this problem is related to forums or not. "next": "^11.0.0" "react": "^17.0.2" import { getGlobalMatrix, Matrix2D } from "./utils/matrix.js"; Link to comment Share on other sites More sharing options...
OSUblake Posted November 11, 2021 Share Posted November 11, 2021 Hi raana, Next.js does not support ES Modules by default, so you'll need to import the UMD files from the dist folder. import { gsap } from "gsap/dist/gsap"; import { Draggable } from "gsap/dist/Draggable"; gsap.registerPlugin(Draggable); 1 1 Link to comment Share on other sites More sharing options...
raana Posted November 11, 2021 Author Share Posted November 11, 2021 Thank you a lot 💐 Link to comment Share on other sites More sharing options...
raana Posted November 11, 2021 Author Share Posted November 11, 2021 @OSUblake hi again. I used import {gsap} from "gsap / dist / gsap"; But it still has a problem. Link to comment Share on other sites More sharing options...
OSUblake Posted November 11, 2021 Share Posted November 11, 2021 That error might be coming from server side rendering as client side scripts won't work. Try checking for a window object first like this... if (typeof window !== "undefined") { gsap.registerPlugin(Draggable, InertiaPlugin); } Or register it inside an effect as those won't run server side. useEffect(() => { gsap.registerPlugin(Draggable, InertiaPlugin); }, []); 2 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