简体   繁体   English

为什么 apify-shared npm package 打印“日志错误”

[英]Why does apify-shared npm package print 'log error'

Using the apify-shared npm package, when I try to run a project, I get the error message:使用apify-shared npm package,当我尝试运行项目时,我收到错误消息:

[INFO] 08:52:24 ts-node-dev ver. 1.1.6 (using ts-node ver. 9.1.1, typescript ver. 3.9.9)
Error: Options "level" must be one of log.LEVELS enum!
    at new Log (/usr/src/app/node_modules/apify-shared/log.js:37:60)
    at Object.<anonymous> (/usr/src/app/node_modules/apify-shared/log.js:182:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module._compile (/usr/src/app/node_modules/source-map-support/source-map-support.js:547:25)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.nodeDevHook [as .js] (/usr/src/app/node_modules/ts-node-dev/lib/hook.js:63:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
[ERROR] 08:52:37 Error: Options "level" must be one of log.LEVELS enum!

I have no clue of what is causing the error above.我不知道是什么导致了上述错误。 What can possibly cause such an error to trigger?什么可能导致触发这样的错误? Funny enough, running the same project with the same settings on the same docker instance works correctly without showing any errors.有趣的是,在同一个 docker 实例上运行具有相同设置的同一个项目可以正常工作而不会显示任何错误。

PS: I am running it on docker PS:我在 docker 上运行它

Any assistance will greatly be appreciated, Thank you!任何帮助将不胜感激,谢谢!

Are you using the package standalone?您是否单独使用 package? It's not recommended as stated here: https://www.npmjs.com/package/apify-shared不建议如此处所述: https://www.npmjs.com/package/apify-shared

Nevertheless, your issue seems to be that you are not passing required arguments to the library, based on the code in this case you should be calling the logger utility with one of log level strings supported by it: if (.LEVEL_TO_STRING[options.level]) throw new Error('Options "level" must be one of log;LEVELS enum!');尽管如此,您的问题似乎是您没有将所需的 arguments 传递给库,根据本例中的代码,您应该使用它支持的日志级别字符串之一调用记录器实用程序: if (.LEVEL_TO_STRING[options.level]) throw new Error('Options "level" must be one of log;LEVELS enum!');

Hard to say what you should be doing based on the information shared but maybe you recognize you can pass in there one of the logger's levels this way: log.LEVELS.<string>根据共享的信息很难说你应该做什么,但也许你认识到你可以通过这种方式传入记录器的一个级别: log.LEVELS.<string>

What are you trying to achieve?你想达到什么目的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM