Cannot find namespace NodeJS

Recently, when trying to use ky, I encountered this error:

error TS2503: Cannot find namespace 'NodeJS'.
2 type UndiciBodyInit = ArrayBuffer | AsyncIterable<Uint8Array> | Blob | FormData | Iterable<Uint8Array> | NodeJS.ArrayBufferView | URLSearchParams | null | string;

To fix this, install @types/node.

Terminal window
npm install @types/node -D

Then add node to the types array in tsconfig.json.

tsconfig.json
{
"extends": "@coras/tsconfig/base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"typeRoots": ["node_modules/@types"],
"module": "esnext",
"lib": ["esnext", "dom"],
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist", "src/**/*.tests.ts"]
}

🎉