uNmAnNeR / imaskjs

vanilla javascript input mask

Home Page:https://imask.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use import statement outside a module: import './controls/input.js'; since Version 7.0.0

mla-v-office opened this issue · comments

Hi,

I can't use Version 7.0.0 of @imask/svelte I get the following error. Version 6.6.1 was fine.
Can this be fixed for the next 7.X Version? Thx

(node:6769) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/workspaces/..../node_modules/imask/esm/imask.js:1
import './controls/input.js';
^^^^^^

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) {
  loc: undefined,
  plugin: undefined,
  pluginCode: undefined,
  hint: undefined
}

Node.js v18.16.0

Having the same issue

@AbstractFruitFactory @mla-v-office hi, can you give me an example?
i created simple node js project with index.js:

const IMask = require('imask');

console.log(IMask.DIRECTION);

and it works fine

then i set "type": "module" in it's package.json and then i can use import in my index.js:

import IMask from 'imask';

console.log(IMask.DIRECTION);

also good. So I refuse to believe that the mask is the problem here.

@uNmAnNeR
Hi sure,
package is of type module.

import {IMask} from '@imask/svelte'

  • I added the @imask/svelte info to the issue

should be fixed in v7.1.1

Howdy @uNmAnNeR!

I just ran into this issue when trying to use this in a Nuxt 2 project and ended up needing to add vue-imask and imask to the build.transpile option of nuxt.config.ts. Would you be wiling to add details for that to the readme to make it easier for others?

And just to add details: I learned about this fix via the thread: nuxt/nuxt#9223