Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Cannot find name 'console'. What could be the reason for this?

The following snippet shows a typescript error at LINE 4:

import {Message} from './class/message';

function sendPayload(payload : Object) : any{
   let message = new Message(payload);
   console.log(message);   // LINE 4 
}

The error says:

[ts] Cannot find name 'console'.

What could be the reason for this? Why it cannot find the object console?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You will have to install the @types/node to get the node typings, You can achieve that by executing the below command,

npm install @types/node --save-dev

Hope this helps!

over 4 years ago · Santiago Trujillo Report

0

Add "dom" in your lib section in compilerOptions in tsconfig.json.

Example:

{
    "compilerOptions": {
        "rootDir": "src",
        "outDir": "bin",
        "module": "commonjs",
        "noImplicitAny": false,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true,
        "target": "es5",
        "lib": [
            "es6",
            "dom"    <------- Add this "dom" here
        ],
        "types": [
            "reflect-metadata"
        ],
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    }
}
over 4 years ago · Santiago Trujillo Report

0

You can run npm install @types/node -D, and then you need to add types:[ 'node'] into your tsconfig.json also.

package.json

"devDependencies": {
    "@types/node": "^15.0.3"
}

tsconfig.json

{
  "compilerOptions": {
    "composite": true,
    "outDir": "./dist",
    "rootDir": ".",
    "declaration": true,
    "noImplicitAny": true,
    "esModuleInterop": true,
    "module": "commonjs",
    "target": "es6",
    "types": [
      "node"
    ],
    "lib": [
      "es6"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ]
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!