vuejs-tips / vue-the-mask

Tiny (<2k gzipped) and dependency free mask input for Vue.js
https://vuejs-tips.github.io/vue-the-mask/
1.72k stars 212 forks source link

nuxt3 import #208

Open Ischafak opened 8 months ago

Ischafak commented 8 months ago

[nuxt] [request error] [unhandled] [500] Named export 'mask' not found. The requested module '/node_modules/vue-the-mask/dist/vue-the-mask.js' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'node_modules/vue-the-mask/dist/vue-the-mask.js'; const { mask } = pkg;

when i try to build i get this error

import vmask from 'vue-the-mask';

export default defineNuxtPlugin((nuxtApp) => { nuxtApp.vueApp.directive( "mask", vmask.mask ) })

this is my mask.js plugin file

viniciusNoleto commented 6 months ago

Hello! I use Nuxt 3 and this worked for me:

import VueTheMask from 'vue-the-mask';

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VueTheMask);
})