在TypeScript工程中使用node模块需要进行require操作,require操作会导致编译的时候报如下错误“This syntax requires an imported helper but module 'tslib' cannot be found.”
解决方案如下:
1、在项目目录下安装tslib
npm install tslib
2、tsconfig.json中“compilerOptions”选项下新增“baseUrl”及“paths”配置
"baseUrl":".",
"paths": {
"tslib" : ["node_modules/tslib/tslib.d.ts"]
}