node.js - “npm ERR!code ELIFECYCLE”在标准输出或调试文件中没有更多信息
问题描述
我在 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
有 flag --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 "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)
Error: the string "Reload wait timeout 1000ms exceeded" 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 "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)
Error: the string "Reload wait timeout 1000ms exceeded" was thrown, throw an Error :)</failure>
</testcase>
这就是构建失败的根本原因。
经验法则是:
查找可能已保存命令输出的文件。
output
带有,logfile
等字样的标志redirect
是潜在的输出重定向器。
这不是一个确定的解决方案。您可能无法访问 CI 等上的这些文件。但是,在绝望之前,我会尝试这个经验法则。
推荐阅读
- javascript - 使用 Javascript 或 Lodash 过滤嵌套数组
- arrays - 在列表中显示对象数组时如何使用 *ngIf 创建断点?
- java - 错误显示当我清楚地将它写在它所指的类中时,方法是未定义的,用Java?
- java - 根据开始日期和结束日期创建通知时间线?
- security - GitHub Action Repository Secrets & 如何保护 client_payload repo 调度事件 Azure Container Registry
- jupyter-notebook - Google Colab 中的 Dataprep.eda
- javascript - Angular - 在选择所有选项之前禁用按钮
- c# - 排序列表
C#中的字母数字 - java - 当我尝试执行“OkHttpClient.execute()”时应用程序关闭
- javascript - Jquery无限滚动仅适用于页面重新加载