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.

ReferenceError: Buffer is not defined

See original GitHub issue

Seems like starknet.js is depending on libraries relying on polyfills (like Buffer) which modern framework do not like

Using vite.js I get

ReferenceError: Buffer is not defined
    at ../node_modules/.pnpm/@ledgerhq+devices@6.27.1/node_modules/@ledgerhq/devices/lib/hid-framing.js (http://localhost:3000/node_modules/.vite/starknet.js?v=53067631:25687:13)
    at __require2 (http://localhost:3000/node_modules/.vite/chunk-UC7LELEO.js?v=53067631:48:44)
    at ../node_modules/.pnpm/@ledgerhq+hw-transport-webhid@6.27.1/node_modules/@ledgerhq/hw-transport-webhid/lib-es/TransportWebHID.js (http://localhost:3000/node_modules/.vite/starknet.js?v=53067631:28215:37)
    at __init (http://localhost:3000/node_modules/.vite/chunk-UC7LELEO.js?v=53067631:45:50)
    at ../node_modules/.pnpm/starknet@3.9.0/node_modules/starknet/dist/signer/ledger.js (http://localhost:3000/node_modules/.vite/starknet.js?v=53067631:28687:50)
    at __require2 (http://localhost:3000/node_modules/.vite/chunk-UC7LELEO.js?v=53067631:48:44)
    at ../node_modules/.pnpm/starknet@3.9.0/node_modules/starknet/dist/signer/index.js (http://localhost:3000/node_modules/.vite/starknet.js?v=53067631:28812:18)
    at __require2 (http://localhost:3000/node_modules/.vite/chunk-UC7LELEO.js?v=53067631:48:44)
    at ../node_modules/.pnpm/starknet@3.9.0/node_modules/starknet/dist/account/default.js (http://localhost:3000/node_modules/.vite/starknet.js?v=53067631:29057:20)
    at __require2 (http://localhost:3000/node_modules/.vite/chunk-UC7LELEO.js?v=53067631:48:44)

Any idea how to get passed that ?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
dhruvkelawalacommented, Apr 25, 2022

As I can see the error seems to be coming from ledger dependencies used in starknet.js. @ledgerhq/hw-transport-webusb this dependency is causing the issue.

If you go on their github, you will find the open issue

0reactions
janek26commented, Aug 4, 2022

should be solved as ledger was removed

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 >
Uncaught ReferenceError: Buffer is not defined #2248 - GitHub
If you install polyfill buffer package, you get the error: It appears you're using a module that is built in to node, but...
Read more >
Buffer is not defined. Using Phantom Wallet, Solana and ...
testing - Uncaught ReferenceError: Buffer is not defined. Using Phantom Wallet, Solana and React to make a transaction - Solana Stack Exchange. ...
Read more >
ReferenceError: Buffer is not defined - Homey Community Forum
I am running Homey 7.4.1 and HomeyScript v3.3.0. Restarted HomeyScript and also have restarted Homey. No change. No other installs etc done.
Read more >
How to polyfill Buffer with Webpack 5 - viglucci.io
The "buffer is not defined" error is a common error that can occur when trying to use the Buffer Node.js API in an...
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