[英]Jenkins-Error: Cannot find module 'typescript'
我有一個jenkins管道,正在嘗試掃描有角度的網站中的聲納爾貝,並且遇到了以下錯誤:
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
我在詹金斯的設置是這樣的:
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
}
}
}
我已經完成了通常的工作,安裝了打字稿(通過npm下載並通過npm),但是每次遇到相同的錯誤時,我都會這樣做。 同樣發生的一件奇怪的事情是,當我刪除舞台並保存時,管道仍在進行分析。
有人知道該怎么做嗎?
謝謝
經過幾個小時的思考,我來到了解決方案,然后讓我解釋原因。 該項目是從git(bitbucket)下載的,在該解決方案中,我們永遠不允許簽入node_modules。因此,在這種情況下,node_modules不存在。 第二個問題(這是我無法控制的),沒有安裝bash命令的實例,而是有人決定安裝powershell插件,我必須處理它。 解決方案是在腳本中添加powershell,最終結果是
steps {
withSonarQubeEnv('Dev-build-01') {
powershell '''
cd D:/SonarQube/abcd-webapp
rmdir /q/s node_modules
del package-lock.json
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
}
}
}
最后,我的管道已修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.