执行npm run sonarqube-scanner-node命令时出错

时间:2017-07-21 12:25:42

标签: node.js npm webpack sonarqube

在cmd中执行 npm run sonarqube-scanner-node 命令时出错

E:...>npm run sonarqube-scanner-node

[17:04:46] Executing sonarqube-scanner ...
node_modules\sonarqube-scanner-node\dist\sonar-scanner-3.0.3.778\bin\sonar-scann
er.bat
child_process.js:504
throw err;
^

Error: spawnSync ...\git\zara-cargo-mobile\node_modules\sonarqube
-scanner-node\dist\sonar-scanner-3.0.3.778\bin\sonar-scanner.bat ENOENT
at exports._errnoException (util.js:1018:11)
at spawnSync (child_process.js:459:20)
at execFileSync (child_process.js:496:13)
at Object. (...\git\zara-cargo-mobile\node_modules
\sonarqube-scanner-node\src\index.js:18:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\
node_modules\npm\bin\npm-cli.js" "run" "sonarqube"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

我还在https://www.npmjs.com/package/sonarqube-scanner-node的浏览器中测试了sonarqube-scanner-node。它也无法正常工作。

Error Stack Trace Viewer
Error: spawnSync /app/available_modules/1500637668000/sonarqube-scanner-node/dist/sonar-scanner-3.0.3.778/bin/sonar-scanner ENOENT
at util._errnoException in core util.js — line 1022
at child_process.spawnSync in core child_process.js — line 461
at child_process.execFileSync in core child_process.js — line 498
in sonarqube-scanner-node/src/index.js — line 18
node.js startup…

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

我使用了声纳扫描程序包,并按照https://www.npmjs.com/package/sonar-scanner链接。

我在package.json中传递了sonar-scanner.bat的完整路径(在正确的代码部分显示)并成功运行。

错误代码:(如文档所示)

https://www.google.com

正确代码:

{
  "scripts": {
    "sonar-scanner": "node_modules/sonar-scanner/bin/sonar-scanner"
  }
}