找不到名称 'console'
Cannot find name 'console'
我正在使用 Angular2-Meteor、TypeScript。 (流星版本 1.3.2.4)
当我在服务器端使用console.log('test');
时,它运行良好。
但是,我在终端中收到此警告:
Cannot find name 'console'.
我怎样才能摆脱这个警告?
或者服务器端有什么特殊的方法比如Meteor.log
?谢谢
How can I get rid of this warning?
如果它是 TypeScript 编译器警告(而不是运行时警告),则 console
在 lib.d.ts
中定义:https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html
确保编译器设置正确(例如,没有 --noLib
或一些自定义的 不正确的 --lib
)。您可能想查看您的 tsconfig.json
的 compilerOptions
(如果有)
@barbatus 是 angular2-meteor 的主要贡献者,在 Github 上给出了答案。
问题在于 TypeScript 包在服务器端使用 lib.core.ts 默认库,它没有控制台定义。来自另一方的 NodeJS 定义现在仅在全局范围内定义控制台(即 global.console)。
解决方案是 运行 在您的终端中:
typings install registry:env/meteor --ambient
请前往here了解更多详情。
我正在使用 Angular2-Meteor、TypeScript。 (流星版本 1.3.2.4)
当我在服务器端使用console.log('test');
时,它运行良好。
但是,我在终端中收到此警告:
Cannot find name 'console'.
我怎样才能摆脱这个警告?
或者服务器端有什么特殊的方法比如Meteor.log
?谢谢
How can I get rid of this warning?
如果它是 TypeScript 编译器警告(而不是运行时警告),则 console
在 lib.d.ts
中定义:https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html
确保编译器设置正确(例如,没有 --noLib
或一些自定义的 不正确的 --lib
)。您可能想查看您的 tsconfig.json
的 compilerOptions
(如果有)
@barbatus 是 angular2-meteor 的主要贡献者,在 Github 上给出了答案。
问题在于 TypeScript 包在服务器端使用 lib.core.ts 默认库,它没有控制台定义。来自另一方的 NodeJS 定义现在仅在全局范围内定义控制台(即 global.console)。
解决方案是 运行 在您的终端中:
typings install registry:env/meteor --ambient
请前往here了解更多详情。