Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

"Uncaught SyntaxError: Cannot use import statement outside a module" error while using parcel v2 #105

Open
Berava opened this issue May 13, 2022 · 0 comments

Comments

@Berava
Copy link

Berava commented May 13, 2022

I would like to integrate Duet Date Picker to my project. I am using parcel v2 as a bundler.

Describe the bug
I get this error regarding two scripts that I'm trying to load from my index.html file:

Capture d’écran 2022-05-13 à 10 30 19

<script type="module" src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.js"></script>

The problem only occurs when I'm using Parcel to bundle my code.

package.json file:

{
  "name": "my-form",
  "version": "1.0.0",
  "source": [
    "src/index.html"
  ],
  "browserslist": "> 0.5%, last 2 versions, not dead",
  "scripts": {
    "dev": "parcel",
    "build": "parcel build src/*.html",
    "format": "prettier --ignore-path ./.gitignore --write \"./**/*.{html,json,js,ts,css}\"",
    "format:check": "prettier --ignore-path ./.gitignore --check \"./**/*.{html,json,js,ts,css}\"",
    "lint": "eslint --ignore-path ./.gitignore --fix \"./**/*.{js,ts}\"",
    "lint:check": "eslint --ignore-path ./.gitignore --quiet \"./**/*.{js,ts}\""
  },
  "devDependencies": {
    "eslint": "^8.14.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-import": "^2.26.0",
    "parcel": "^2.5.0",
    "postcss-import": "^14.1.0",
    "postcss-plugin": "^1.0.0",
    "posthtml-include": "^1.7.3",
    "prettier": "^2.6.2"
  }
}

To Reproduce
When I hit "npm run dev", I get the "Uncaught SyntaxError: Cannot use import statement outside a module" error and the scripts do not load.

Additional context
I tried adding a "type": "module" as a top-level attribute to the package.json file but it still doesn't work.

Would really appreciate any help with this issue, thanks in advance !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant