-
Using xlsx in a project. In development, running into the following error: Uncaught (in promise) Error: Module "fs" has been externalized for browser compatibility. Cannot access "fs.writeFileSync" in client code. Within xlsx, it checks whether the environment is node or browser. var _fs;
if(typeof require !== 'undefined') try { _fs = require('fs'); } catch(e) {} However, vite during the dependency bundling step to convert commonjs to esm defines
Is there a way to configure vite to avoid defining Found a hacky workaround
Is there a permanent solution either with vite or in xlsx? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Solved by updating xlsx to v18 which supports ESM via |
Beta Was this translation helpful? Give feedback.
-
I has a similar issue when to replace
I'm not sure if I have to open this issue here instead! |
Beta Was this translation helpful? Give feedback.
Solved by updating xlsx to v18 which supports ESM via
module: xlsx.mjs
andexports
fields.