Cannot use import statement outside a module after build in Parceljs

  html, import, javascript, parcel

I am using Parcel.js in my project and build the project and upload to my server but when go to my website, the import modules doesn’t work but in dev yes. Display this error:

Cannot use import statement outside a module

I saw the documentation for parcel.js but can’t find a solution

How i can solve this?

When import

import LocomotiveScroll from 'locomotive-scroll';
import Splide from '@splidejs/splide';
import {gsap} from 'gsap';
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { CSSRulePlugin } from "gsap/CSSRulePlugin";

Package.json

 {
      "name": "el-quelite",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "type": "module",
      "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "@babel/core": "^7.14.0",
        "cssnano": "^5.0.2"
      },
      "babel": {
        "presets": [
          "@babel/preset-react"
        ]
      },
      "dependencies": {
        "@babel/preset-react": "^7.13.13",
        "@splidejs/splide": "^2.4.21",
        "autoprefixer": "^9.8.6",
        "gsap": "^3.6.1",
        "index.js": "0.0.3",
        "locomotive-scroll": "^4.1.1",
        "parcel": "^2.0.0-nightly.649",
        "postcss": "^8.0.0",
        "postcss-cli": "^8.0.0",
        "postcss-loader": "^4.0.3"
      },
      "browserslist": [
        "defaults",
        "not IE 11",
        "maintained node versions"
      ]
    }

Source: Ask Javascript Questions

LEAVE A COMMENT