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.

vue3+vite reports Uncaught ReferenceError: Buffer is not defined

See original GitHub issue

Describe the bug

version: “vue”: “^3.2.16”, “vite”: “^2.6.4”

Buffer is used for data conversion in the vue3+vite project, and the running project reports Uncaught ReferenceError: Buffer is not defined

Reproduction

The project git repository is: https://github.com/LQS5858/newmall-vue3-vite

System Info

System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 351.83 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.4 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/bin/npm
  Browsers:
    Safari: 14.1.2

Used Package Manager

npm

Logs

No response

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
8bucommented, Dec 8, 2021
1reaction
8bucommented, Dec 8, 2021

@Niputi sorry my bad https://github.com/8bu/vue-vite-web3

Maybe it’s a problem with web3, you can try this in vite.config.ts: resolve: { alias: { web3: path.resolve(__dirname, './node_modules/web3/dist/web3.min.js') }, }

hmm thank u. I totally forgot about the prebuilt version. Lemme try it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: Buffer is not defined - Stack Overflow
Answering my own question. Two things helped to resolve the issue: Adding plugins section with ProviderPlugin into webpack.config.js.
Read more >
Buffer is not defined. Using Phantom Wallet, Solana and ...
This is happening because the default bundler that comes with create react app(webpack 5) does not polyfill Buffer .
Read more >
vite搭建vue3的项目中,ReferenceError Buffer is not defined
问题:. 下载文件,后端返回buffer,前端下载;浏览器报 ReferenceError: Buffer is not defined. Buffer is not defined ...
Read more >
MongoDB 3.6 shell "Buffer is not defined" - Developer Tools
Hi,. I write a js script for mongodb 3.6.3 (Ubuntu 18.04) where I want to use js / nodejs “Buffer”, but script execution...
Read more >
How to polyfill Buffer with Webpack 5 | viglucci.io
How to fix 'buffer is not defined' error and polyfill the Node.js Buffer ... new Buffer(); Uncaught ReferenceError: Buffer is not defined at ......
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