简体   繁体   中英

My javascript won't work on my OVH server

I'm currently working on a portfolio and I wanted to upload it on a server so I could show it to people on any computer. Here is the "stack" of my website: HTML / CSS / SCSS / JS (native + GSAP)

In my local environment, everything is working fine (like literally 0 issue)

Id uploaded my website on an OVH server (it worked for other projects so I don't think the issue is there but idk..)

My issue is, when I lookup my website, there is no javascript. It is due to an error :

Cannot use import statement outside a module (at script.js:1:1).

The concerned line is :

import { gsap } from "gsap"; 

I already looked that up on internet and tried various solutions (adding type: module in package.json, change paths, replace 'import' by 'require', etc..), yet nothing has worked, and I can't "publish" this website.

Would anybody have an explication regarding all thoses details ?

You probably have gsap on your node_modules folder, which might not be in your website. Instead of using it installed by npm, use the <script> tag in you html file as suggested by the gsap docs:

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM