Adding @types/node to Angular

Ole Ersoy
Mar 20, 2020

--

Image by Devanath from Pixabay

Scenario

We run into something like this:

node_modules/gray-matter/gray-matter.d.ts:43:11 — error TS2591: Cannot find name ‘Buffer’. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.

Approach

npm i -S @types/node

Then in tsconfig.json

"angularCompilerOptions": {
"types" : ["node"]
....
}

--

--