TS Error with Node Compatibility Buffer API?

According to the docs (https://developers.cloudflare.com/workers/runtime-apis/nodejs/buffer/), one should import the Buffer API like this:
import { Buffer } from 'node:buffer';
import { Buffer } from 'node:buffer';
However, I get the following TS error:
Cannot find module 'node:buffer' or its corresponding type declarations.
Cannot find module 'node:buffer' or its corresponding type declarations.
I'm pretty sure this is just a tsconfig.json problem, but I can't seem to figure it out.
1 Reply
micromashor
micromashorOP17mo ago
figured it out (how did i not check this before 🤦‍♂️ ): 1) npm install @types/node 2) in tsconfig.json, add "node/buffer" to the types array
Want results from more Discord servers?
Add your server