我有一个Jenkins Pipeline,在尝试使用SonarQube扫描Angular网站时遇到了这个错误:
ERROR: internal/modules/cjs/loader.js:582
ERROR: throw err;
ERROR: ^
ERROR:
ERROR: Error: Cannot find module 'typescript'
ERROR: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
ERROR: at Function.Module._load (internal/modules/cjs/loader.js:506:25)
ERROR: at Module.require (internal/modules/cjs/loader.js:636:17)
ERROR: at require (internal/modules/cjs/helpers.js:20:18)
ERROR: at Object.<anonymous> (D:\SonarQube\ajbic-client-app\.scannerwork\sonarts-bundle\node_modules\tslint\lib\language\walker\blockScopeAwareRuleWalker.js:20:10)
ERROR: at Module._compile (internal/modules/cjs/loader.js:688:30)
ERROR: at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
ERROR: at Module.load (internal/modules/cjs/loader.js:598:32)
ERROR: at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
ERROR: at Function.Module._load (internal/modules/cjs/loader.js:529:3)
ERROR: Failed to find 'typescript' module. Please check, NODE_PATH contains location of global 'typescript' or install locally in your project
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
Jenkins中我的设置如下:
steps {
withSonarQubeEnv('Dev-build-01') {
bat "cd D:/SonarQube/abcd-webapp"
bat "rm -rf node_modules package-lock.json"
bat "npm install"
bat "C:/Jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQubeScanner/Net/bin/sonar-scanner.bat -D sonar.projectKey=abcd-webapp -D sonar.sources=src -D sonar.login=667723c08ecfe0fc0d5c0e91bdd5c4b219e851e7 -D sonar.projectBaseDir=D:/SonarQube/abcd-webapp"
}
timeout(time: 60, unit: 'MINUTES') {
// waitForQualityGate abortPipeline: true
}
}
}
我已经做了通常的事情,安装typescript(通过下载和npm),但每次都出现相同的错误。 还有一件奇怪的事情发生,当我删除阶段并保存时,管道仍然会进行分析。
有人知道该怎么办吗?
谢谢