ts-node的使用问题

关于ts-node 的介绍

https://www.cnblogs.com/makalochen/p/14510330.html#简化执行ts的步骤

问题

ts-node 是一个可以直接运行 ts 文件的 npm 工具包。如果是初次使用,直接运行 typescript 代码可能会遇到这种报错:

Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.

image-20230329161246865

解决方法

以下两种方法任选其一即可:推荐使用第一种

1.ts-node 版本过高,降低一下版本就好了。

npm i -g [email protected]

2.全局安装 ts-node 运行依赖包 tslib@types/node

npm i -g tslib @types/node
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章