Cannot find name ‘XX‘. Do you need to change your target library
Posted 天渺工作室
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cannot find name ‘XX‘. Do you need to change your target library相关的知识,希望对你有一定的参考价值。
typescript 在编译运行的时候或ts-node xxx.ts运行的时候 报错
不管是Set Map 还是啥其他的es6新语法编译报错
Cannot find name \'Map(编译不了的哪一项)\'. Do you need to change your target library? Try changing the `lib` compiler option to \'es2015\' or later
如果当前项目没有tsconfig.json 配置文件
请执行
//生成tsconfig.json 编译配置文件
tsc -init
将tsconfig.json中的配置项
"target": "es5", 改成 "target": "es6",
提示说的很清楚了,意思就是让咱修改个编译时需要引入的库,为什么会出现这种原因,是因为咱们在ts的配置里面配置target为es5时,它默认注入的库为ES5...... 显然Set,Map......(es6的那些新语法)在es5时是不存在,所以就编译失败。
以上是关于Cannot find name ‘XX‘. Do you need to change your target library的主要内容,如果未能解决你的问题,请参考以下文章
Cannot find name ‘Set‘. Do you need to change your target library? Try changing the `lib` compiler o
Cannot find name ‘Set‘. Do you need to change your target library? Try changing the `lib` compiler o
Cannot find command ‘git‘ - do you have ‘git‘ installed and in your PATH?
ERROR: Cannot find command ‘git‘ - do you have ‘git‘ installed and in your PATH