TS2584
error TS2584: Cannot find name ‘console’. Do you need to change your target library? Try changing the ‘lib’ compiler option to include ‘dom’.
Broken Code ❌
TypeScript code:
1 |
|
TypeScript compiler configuration (tsconfig.json
):
1 |
|
Fixed Code ✔️
You have to add the following to your “tsconfig.json” file:
1 |
|
When you are working on an application which never runs in a browser but only in Node.js environments, then you could add @types/node
to your devDependencies
instead of adding "dom"
to your "lib"
section.