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
    评论
SonarQube是一种用于代码质量管理和静态代码分析的工具,它可以对各种编程语言的源代码进行扫描和分析。当需要扫描和分析C语言代码时,SonarQube也可以提供相应的功能和支持。 SonarQube的C语言插件可以帮助开发团队检测和修复源代码中的各种问题,从而提高代码的质量和可靠性。它可以扫描C语言代码以查找潜在的错误、漏洞、代码规范问题和性能问题等。例如,它可以检测未初始化的变量、空指针引用、内存泄漏、代码重复等问题。 使用SonarQube进行C代码扫描可以帮助开发团队及时发现和解决潜在的问题,从而减少bug的数量,并提高代码的可维护性和可读性。此外,SonarQube还提供了可视化的报告和仪表板,帮助开发团队了解代码质量的整体情况,并提供改进的建议。 为了使用SonarQube扫描C语言代码,首先需要配置SonarQube服务器并安装C语言插件。然后,通过将代码仓库与SonarQube服务器进行集成,并在构建过程中使用特定的构建工具或构建插件,可以实现自动化的扫描和分析。在扫描完成后,SonarQube会生成报告,并在其Web界面中显示代码质量的细节和指标。 总之,SonarQube是一个强大的静态代码分析工具,可用于扫描和分析C语言代码。它提供了丰富的功能和报告,帮助开发团队提高代码质量、降低风险,并增强软件的可维护性和可读性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值