ReferenceError: Buffer is not defined on import in Nuxt3/Vue3
rotsee opened this issue · 2 comments
rotsee commented
Describe the bug
Trying to import parse
fails in Nuxt and Vue codes with the error message ReferenceError: Buffer is not defined
To Reproduce
In a page or component, add the following import inside the script tag:
<script setup>
import { parse } from 'csv-parse/sync'
...
</script>
Then try navigating to that page
Additional context
Let me know if there is anything I can do that helps troubleshooting this.
wdavidw commented
I don't use these environment but you shall try the following distributions:
- https://csv.js.org/project/distributions/browser_esm/
- https://csv.js.org/project/distributions/browser_iife/
For example, with your example above:
<script setup>
import {parse} from 'csv-parse/browser/esm';
...
</script>
rotsee commented
Thank you, using the browser dists works in all rendering modes in Nuxt, it seems!