ReferenceError: Buffer is not defined #143
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
when i use gray-matter in vite react project, found this error:
how to fix
Install this library
add this import to your vite.config.js
and add this in your vite.config.js
Wow rarely I find solutions that work straight away, thanks @tomatobybike !
Would be nicer if this library was compatible with the browser to begin with, or add a browser build defined in the
package.jsonIt seems optimizeDeps isn't run on
vite build...vite-plugin-node-polyfills should solve both dev/build problem. See: https://www.npmjs.com/package/vite-plugin-node-polyfills
if use nuxtjs, see https://github.com/nuxt/nuxt/issues/25016
Yes this works but when I checked the matter, it has
contentas html data with also includes the metadeta which I included in the--- ... ---and the data field was an empty object.did work for me in a quasar vue.js vite setup.
quasar.conf.jsin tauri+react project, this should work:
None of the above worked for me. What worked though was installing https://www.npmjs.com/package/vite-plugin-node-polyfills. I also had to remove the
node-globals-polyfillplugin or the dev environment would break.EDIT: Someone had already mentioned this plugin but for some reason I didn't notice lol. I'll still leave this here in case someone has the same problem, for clarity's sake.
the author already solves the problem for me, the issue can be close
Using polyfills is not a solution — it's finicky at best if you have any real dependencies. It would not be difficult to fix this in any number of ways:
If I have the time to do this I will make a PR... but the activity on this repo doesn't exactly scream confidence for it being accepted...
Edit: I found two alternatives with proper ESM exports and browser support: