"npm ERR! code ELIFECYCLE" 标准输出或调试文件中没有更多信息

"npm ERR! code ELIFECYCLE" without no more information in the stdout or the debug file

我在 CI 服务器上构建失败并显示此消息:

+ npm run coverage

> trololol-cloud-monitor-service@4.3.10 coverage /home/jenkins/workspace/workspace/ololCloud_service-monitor_PR-3568
> nyc --reporter=lcov --include='**/*.js' npm run test:ci

> trololol-cloud-monitor-service@4.3.10 test:ci /home/jenkins/workspace/workspace/erayCloud_service-monitor_PR-3568
> TLL_MONITOR_UPLOAD_WAIT_TIME=0 TLL_DEFAULT_WAIT_TIMEOUT=0 ./node_modules/.bin/mocha --timeout 120000 --reporter=xunit --reporter-options output=./test-results/TEST-results.xml --require @babel/register  --exit ./test/monitor-unit-test-suite.js

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! trololol-cloud-monitor-service@4.3.10 test:ci: `TLL_MONITOR_UPLOAD_WAIT_TIME=0 TLL_DEFAULT_WAIT_TIMEOUT=0 ./node_modules/.bin/mocha --timeout 120000 --reporter=xunit --reporter-options output=./test-results/TEST-results.xml --require @babel/register  --exit ./test/monitor-unit-test-suite.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the trololol-cloud-monitor-service@4.3.10 test:ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jenkins/.npm/_logs/2021-10-21T19_09_07_920Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! trololol-cloud-monitor-service@4.3.10 coverage: `nyc --reporter=lcov --include='**/*.js' npm run test:ci`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the trololol-cloud-monitor-service@4.3.10 coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jenkins/.npm/_logs/2021-10-21T19_09_08_438Z-debug.log
script returned exit code 1

这些日志中没有任何信息,提到的文件2021-10-21T19_09_08_438Z-debug.log也没有任何其他信息。

如何找到我需要的信息?

TL;DR: 查找可能保存错误消息的文件。控制台输出中可能会有提示。


由 NPM 调用的应用程序打印所需信息。换句话说:您可能应该更改您的构建代码(可能是您的 package.json)以显示您需要的日志。通常,它不实用甚至不可行,但这是一般方法。

OTOH,有时信息会被发送到不同的地方。例如,考虑下面的行,从问题的输出中提取并分成几行以提高易读性:

npm ERR! trololol-cloud-monitor-service@4.3.10 test:ci: 
  `TLL_MONITOR_UPLOAD_WAIT_TIME=0\TLL_DEFAULT_WAIT_TIMEOUT=0 ./node_modules/.bin/mocha 
    --timeout 120000
    --reporter=xunit
    --reporter-options output=./test-results/TEST-results.xml
    --require @babel/register
    --exit ./test/monitor-unit-test-suite.js`

注意 ./node_modules/.bin/mocha 有标志 --reporter-options output=./test-results/TEST-results.xml。不难想象测试结果被写入文件./test-results/TEST-results.xml。我们的错误消息更有可能存在。

确实,我在那里看了看,发现了这些行:

<testcase
  classname="Utils tests Config Watcher Tests Reload Config"
  name="Should reload configs, after file events" time="1.002">
    <failure>the string &#x22;Reload wait timeout 1000ms exceeded&#x22; was thrown, throw an Error :)
Error: the string &#x22;Reload wait timeout 1000ms exceeded&#x22; was thrown, throw an Error :)</failure>
</testcase>
<testcase
  classname="Utils tests Config Watcher Tests Schedule Reload"
  name="Should reload config, after scheduled reload" time="1.001">
    <failure>the string &#x22;Reload wait timeout 1000ms exceeded&#x22; was thrown, throw an Error :)
Error: the string &#x22;Reload wait timeout 1000ms exceeded&#x22; was thrown, throw an Error :)</failure>
</testcase>

这就是构建失败的根本原因。

经验法则是:

Look for files where the command's output might have been saved.

带有 outputlogfileredirect 等词的标志是潜在的输出重定向器。

这不是最终的解决方案。您可能无法在 CI 等上访问这些文件。但是,我会在绝望之前尝试这个经验法则。