TypeScript系列 -> 遇到报错 Cannot find name ‘console‘. Do you need to change your target library?ging the ‘lib‘ compiler option
学习ts遇到的报错
Cannot find name ‘console‘. Do you need to change your target library?ging the ‘lib‘ compiler option
解决办法:
- 需要安装TypeScript助手的运行时库,包含所有TypeScript辅助函数
npm install -D tslib @types/node
- 解释:
以下是一个知乎大佬的讲解:console 不属于 EcmaScript 标准。
DOM 里面的 console 是浏览器环境下的,属于浏览器BOM API,Node 里面的 console 是 Node.js 里面的,由nodejs自己定义的API,两者虽然有同样的功能,但是并不是同一个东西;
因此总结,主要原因 TypeScript 自带的类型只有 DOM 环境里面的那些类型(在 lib.dom.d.ts 里面),Node.js 的类型是不自带并且通过 @types/node 这个库来维护的。
作者:Yiming Li
链接:https://www.zhihu.com/question/470016632/answer/1978489216
————————————————
英文参考链接:
Cannot find name '..'. Do you need to change your target library?
TypeScript系列 -> 遇到报错 Cannot find name ‘console‘. Do you need to change your target library?ging the ‘lib‘ compiler option的更多相关文章
- Mac下idea启动H5报错:xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Deve
1. 执行“ xcodebuild -showsdks ”,报错如下“xcode-select: error: tool 'xcodebuild' requires Xcode, but active ...
- hadoop项目开发运行报错(log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).)
使用hadoop+myeclipse开发项目是测试运行报错: log4j:WARN No appenders could be found for logger (org.apache.hadoop. ...
- 连接数据库报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.soc ...
- ROS常见问题(三) 报错are you sure it is properly registered and that the containing library is built?
报错: [FATAL] [1576042404.913706482]: Failed to create the global_planner/GlobalPlanner planner, are y ...
- Egret项目Typescript的编译报错
今天编译项目,出现了一个奇怪的报错,如下: E:\engine\egret-core-3.1.2\tools\lib\typescript\tsclark.js:41531 1> if (fil ...
- 【PaddlePaddle系列】报错解决方法合集 (不定时更新)
1.PaddlePaddle使用CPU时正常运行,但是使用GPU时却报出一堆错误信息,节选如下: paddle.fluid.core.EnforceNotMet: enforce allocating ...
- IE浏览器连接WebSocket报错:java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
在项目开发中整合了WebSocket,本来没什么问题了,但是偶尔发现用IE浏览器打开web端不能推送消息,因为PC端与服务器建立连接失败了.网上查了很多资料, 又看了看源码,都不对症:又怀疑是Spri ...
- nginx 启动报错 1113: No mapping for the Unicode character exists in the target multi-byte code
failed (1113: No mapping for the Unicode character exists in the target multi-byte code page) 因为路径有中 ...
- mysql workbench 报错:Can't analyze file, please try to change encoding type...
Mysql workbench 导入csv can't analyze file 原因: workbench 识别csv第一行作为column名,column名不能为中文,所以报错.解决方法:csv第 ...
- maven打包报错 Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_151\..\lib\tool
maven 打包报错 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:comp ...
随机推荐
- jemter 分布式压测
1.测试机搭建 首选 压力机A,压力机B,压力机C, 压力机A作为控制台 压力机B,压力机C作为分布式的测试机 压力机Aip:172.16.23.69, 压力机Bip:192.168.184.128 ...
- 12组-Alpha冲刺-5/6
一.基本情况 队名:字节不跳动 组长博客:https://www.cnblogs.com/147258369k/p/15562095.html 小组人数:10人 二.冲刺概况汇报 侯钦凯 过去两天完成 ...
- MargeSort
归并排序(Merge Sort)是建立在归并操作上的一种有效,稳定的排序算法,该算法是采用分治法(Divide and Conquer)的一个非常典型的应用.将已有序的子序列合并,得到完全有序的序列: ...
- mybatis-plus 时间查询
QueryWrapper userquery= new QueryWrapper<>(); user.and(true,wrapper -> wrapper.ge("CRE ...
- go-使用 vscore 调试 go 语言
{ // 使用 IntelliSense 了解相关属性. // 悬停以查看现有属性的描述. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linki ...
- 2022强网拟态 WHOYOUARE
2022强网拟态 WHOYOUARE 先说一下这个思路 由于禁用了__proto__所以我们可以通过constructor.prototype来绕过 之前一直不明白为什么是这样绕过的后来仔细研究了一下 ...
- vue 中的 .sync 修饰符 与 this.$emit('update:key', value)
vue 中 .sync 修饰符,是 2.3.0+ 版本新增的功能 在有些情况下,我们可能需要对一个 prop 进行"双向绑定".不幸的是,真正的双向绑定会带来维护上的问题,因为子组 ...
- mblink study111
mblink study https://gitee.com/dotnetchina/NanUIhttps://blog.csdn.net/u012814856/article/details/70 ...
- how to make the windows console works with utf-8 encoded project
the console of the windows os is not working in the utf-8 encoding, by default. When you force your ...
- 解决linux系统中对两个不同的网络连接http访问
项目5G 问题背景:调用网络端的服务器服务,对本地机器人进行控制,以实现机器人应执行的任务. 需求:主机需要访问外网的API,同时在本地局域网与机器人的API进行通信. 问题:要解决HTTP请求发送到 ...