-
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.
Answered by
BrianHung
Jul 17, 2022
Replies: 1 comment 3 replies
-
Solved by updating xlsx to v18 which supports ESM via |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
BrianHung
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved by updating xlsx to v18 which supports ESM via
module: xlsx.mjs
andexports
fields.