joaomede / vue3-xlsx

XLSX manipulation made easy by Vue.js 3 (next) - (fork vue-xlsx)
https://joaomede.github.io/vue3-xlsx/
MIT License
12 stars 3 forks source link

Module "fs" has been externalized for browser compatibility. Cannot access "fs.writeFileSync" in client code. #5

Open shu16 opened 2 years ago

shu16 commented 2 years ago
<xlsx-workbook>
  <xlsx-sheet
    :collection="sheet.data"
    v-for="sheet in sheets"
    :key="sheet.name"
    :sheet-name="sheet.name"
  />
  <xlsx-download>
    <button>Download</button>
  </xlsx-download>
</xlsx-workbook>

When I clicked download button found message below. Module "fs" has been externalized for browser compatibility. Cannot access "fs.writeFileSync" in client code.

I found below. https://github.com/vitejs/vite/discussions/9149 then xlsx update to v0.18.5 but in vain.

FYI my workaround is: add follows to vite.config.ts

resolve: {
    alias: {
      "xlsx": path.resolve(__dirname,  "./node_modules/xlsx/xlsx.mjs")
    },
  },
joaomede commented 2 years ago

can you open a pull request?

shu16 commented 1 year ago

Thanks for your reply. According to https://github.com/vitejs/vite/discussions/9149, I think this issue caused by xlsx and Vite. So maybe all I can do is notify people who are using this package with Vite. So I shouldn't have posted here. It's better to close the issue.

shu16 commented 1 year ago

This package is not responsible for this issue.