Search code examples
javascriptnode.jspuppeteerapifyts-node-dev

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:

[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.

PS: I am running it on docker

Any assistance will greatly be appreciated, Thank you!


Solution

  • Are you using the package standalone? It's not recommended as stated here: 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!');

    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>

    What are you trying to achieve?