question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

safe-buffer in modern build tools like Vitejs

See original GitHub issue

Hey, i’m trying to use ViteJs for project.

Since this is es6 only, the code errors out inside safe-buffer package Buffer is undefined here

Screenshot 2021-04-19 at 11 31 26

If we included this simple check, this wouldn’t error out in ViteJs environment. Screenshot 2021-04-19 at 11 32 12

Is there any reason not to include check like this? If you would be interested, i could submit PR

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

3reactions
phiiilcommented, May 21, 2021

Adding buffer to node_modules fixed this for me.

npm i buffer

No need to change the safe-buffer package.

1reaction
JasonGorecommented, Feb 18, 2022

This should absolutely result in a change in safe-buffer package. buffer should be declared as a dep by safe-buffer in its package.json if it requires it. I found this problem when I noticed that our bundled output is using any random version of buffer it comes across installed by another dependency, regardless of buffer major versioning. This will lead to insidious and hard to troubleshoot and the dep should be declared by safe-buffer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · feross/safe-buffer - GitHub
Safer Node.js Buffer API. Contribute to feross/safe-buffer development by creating an account on GitHub. ... safe-buffer in modern build tools like Vitejs.
Read more >
Uncaught TypeError: Cannot read property 'from' of undefined
I am creating client side app using vitejs bundler and this is the error I am getting: ... safe-buffer in modern build tools...
Read more >
Building for Production - Vite
The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the native ES Modules, native ESM dynamic ...
Read more >
Vite vs. Snowpack: A comparison of frontend build tools
Frontend build tools like Vite and Snowpack leverage native modules to avoid unnecessary work and keep your project fast.
Read more >
Comparison of Build Tools - SurviveJS
Tooling.Report provides a feature comparison of the most popular build tools. ... You can also namespace your scripts using a convention like test:watch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found