Cannot find name 'console'

3.7k Views Asked by At

I am using Angular2-Meteor, TypeScript. (Meteor version 1.3.2.4)

When I use console.log('test'); on the server side, it is working well.

However, I got this warning in my terminal:

Cannot find name 'console'.

How can I get rid of this warning?

Or is there any special method such as Meteor.log for server side? Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

@barbatus who is main contributor for angular2-meteor, gave the answer on Github.

The issue is in that TypeScript package uses lib.core.ts default lib on the server side which doesn't have definitions for console. NodeJS definitions from other side as now defines console in the global scope only (i.e. global.console).

The solution is running this in your terminal:

typings install registry:env/meteor --ambient

Please go here for more details.

1
On

How can I get rid of this warning?

if its a TypeScript compiler warning (and not a runtime one) then console is defined in lib.d.ts : https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html

Make sure that the compiler is setup correctly (e.g. doesn't have --noLib or some custom incorrect --lib). You might want to look at your tsconfig.json's compilerOptions (if any)