t-chatoyan / vue-excel-xlsx

Convert your Data as an XLSX file
MIT License
40 stars 28 forks source link

Cannot use import statement outside a module #23

Open chheng-dev opened 2 years ago

RubensZaes commented 2 years ago

Install libs:

npm i read-excel-file npm i export-from-json

In @types create arquive 'vue-excel-xlsx.d.ts' containing: declare module 'vue-excel-xlsx'

In plugins create excelLib.ts containing:

import VueExcelXlsx from "vue-excel-xlsx"
import Vue from 'vue'

Vue.use(VueExcelXlsx)

In nuxt.config.js add: plugins: [ { src: "@/plugins/excelLib", mode: "client" }, ],

In package.json add: "type": "module",

In tsconfig.json modify:

"target": "ES2018",
    "module": "ESNext",

to

"target": "esnext",
    "module": "commonjs",