Phelar Posted January 20, 2021 Share Posted January 20, 2021 Hi! I´m trying to get started with gsap, but i need some help. This is my html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="keywords" content="HTML, JavaScript"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .test { background-color: black; } </style> </head> <body> <div class="test"> <img class="duck" src="/assets/anka.png" alt="Fin Anka"> </div> <script type="module" src="node_modules/gsap/all.js"></script> <script type="module" src="/app.js"></script> </body> </html> and this is my .js: import {gsap} from './node_modules/gsap' gsap.to(".duck", {duration: 2, x: 300}) AND this is the error: Link to comment Share on other sites More sharing options...
ZachSaucier Posted January 20, 2021 Share Posted January 20, 2021 Hey Phelar and welcome to the GreenSock forums. This error has nothing to do with GSAP. Perhaps this Mozilla docs page can help. Link to comment Share on other sites More sharing options...
Phelar Posted January 20, 2021 Author Share Posted January 20, 2021 1 hour ago, ZachSaucier said: Hey Phelar and welcome to the GreenSock forums. This error has nothing to do with GSAP. Perhaps this Mozilla docs page can help. Hi, thanks! So you mean that the syntax is ok, it should work? Link to comment Share on other sites More sharing options...
ZachSaucier Posted January 20, 2021 Share Posted January 20, 2021 1 hour ago, Phelar said: the syntax is ok The GSAP syntax is fine. 1 hour ago, Phelar said: it should work? Your issue has nothing to do with your GSAP-related code. It has to do with the encoding of your files. 1 Link to comment Share on other sites More sharing options...
Phelar Posted January 20, 2021 Author Share Posted January 20, 2021 Ok, i solved this issue but i get this error when trying to import the gsap module like this import { gsap } from "gsap" i get this error: Uncaught TypeError: Failed to resolve module specifier "gsap". Relative references must start with either "/", "./", or "../" though i can reach and implement the method from the module gsap.to(".duck", {duration: 2, x: 300}) Link to comment Share on other sites More sharing options...
ZachSaucier Posted January 20, 2021 Share Posted January 20, 2021 Why are you opting to use the modules version of GSAP? Most the time if you're using script tags you should load the non-modules version. I highly recommend going through the video about loading GSAP via the script tag in the installation documentation. As for the issue, you'll need to give the full path to the modules version of GSAP if you want to do it that way. Link to comment Share on other sites More sharing options...
Phelar Posted January 21, 2021 Author Share Posted January 21, 2021 22 hours ago, ZachSaucier said: Why are you opting to use the modules version of GSAP? Most the time if you're using script tags you should load the non-modules version. I highly recommend going through the video about loading GSAP via the script tag in the installation documentation. I don´t have a good answere to that I gues it feels more like home... I´ll try the non-module version. 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