SonarQube扫描typescritp问题记录

 使用sonar扫描ts项目时报如下错误,

Failed to find 'typescript' module. Please check, NODE_PATH contains location of global 'typescript' or install locally in your project
ERROR: Error: Cannot find module 'typescript'
ERROR:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
ERROR:     at Function.Module._load (internal/modules/cjs/loader.js:562:25)
ERROR:     at Module.require (internal/modules/cjs/loader.js:692:17)
ERROR:     at require (internal/modules/cjs/helpers.js:25:18)
ERROR:     at Object.<anonymous> (/home/jenkins/data/workspace/coding/test/.scannerwork/sonarts-bundle/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js:20:10)
ERROR:     at Module._compile (internal/modules/cjs/loader.js:778:30)
ERROR:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
ERROR:     at Module.load (internal/modules/cjs/loader.js:653:32)
ERROR:     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
ERROR:     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
ERROR: Failed to find 'typescript' module. Please check, NODE_PATH contains location of global 'typescript' or install locally in your project
ERROR: External process `node --max-old-space-size=2048 /home/jenkins/data/workspace/coding/test/.scannerwork/sonarts-bundle/node_modules/tslint-sonarts/bin/tsrunner` returned an empty output. Run with -X for more information

解决方法:安装typescript,npm install -g typescript

安装完成后执行tsc -v查看,如果tsc命令报错Unexpected token ?,可能是typescript版本不兼容

卸载typescript:npm uninstall -g typescript

指定版本安装,我本地node版本v10.24.1,npm版本6.14.12,安装typescript版本3.5.3

执行:npm install -g typescript@3.5.3

如果安装完成之后还报上面错误,可能是新拉的代码仓库没有安装依赖,执行下npm i就好了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值