alireza-ab / vue3-persian-datepicker

A datepicker component for select date (vue 3)
MIT License
34 stars 2 forks source link

Cannot use import statement outside a module #5

Closed alimirmohammad closed 1 year ago

alimirmohammad commented 1 year ago

Hi there!

Thank you for this package. There is a bug. When I am using this package in a Nuxt3 project, I get the following error:

node_modules/@alireza-ab/vue3-persian-datepicker/dist/index-es.js:1
import {
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1176:20)
    at Module._compile (node:internal/modules/cjs/loader:1218:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

When I modify the package.json file of this package and set the type, the error disappears.

{
    "type": "module"
}

My Nuxt version is 3.3.1. Could you please fix this?

alireza-ab commented 1 year ago

Hi @alimirmohammad I guess you wanted to import the component and use it. you shouldn't import. just use it.

alimirmohammad commented 1 year ago

Hi @alireza-ab

Thank you for the tip. You were right. The Nuxt module registers the component automatically. So I can use it without importing.