cabinjs / axe

:axe: Logger-agnostic wrapper that normalizes logs regardless of arg style. Great for large dev teams, old/new projects, and works w/Pino, Bunyan, Winston, console, and more. It is lightweight, performant, highly-configurable, and automatically adds OS, CPU, and Git information to your logs. Hooks, dot-notation remap, omit, and pick of metadata.
https://forwardemail.net/docs/best-practices-for-node-js-logging
MIT License
50 stars 11 forks source link

Problem with dependency in Axe #8

Closed armenr closed 5 years ago

armenr commented 5 years ago

Hi there - oddly, I'm getting this error when using pnpm packager in place of npm. In any case, what I was able to figure out was that the util-format-x dependency version in axe appears to be really, really old...and from what I can tell, that's what's causing this. When I disable cabin, everything works fine.

Any help or suggestions would be much appreciated.

Thank you!

[nodemon] watching: .env package.json ./server.js
[nodemon] starting `node --require dotenv/config server.js`
/Users/armenr/Desktop/myproj-new/myprojzer0/packages/myproj-proxy/node_modules/.registry.npmjs.org/index-of-x/2.3.0/node_modules/index-of-x/index.js:27
  var res = attempt.call([0, 1], pIndexOf, 1, 2);

TypeError: attempt.call is not a function
    at Object.<anonymous> (/Users/armenr/Desktop/myproj-new/myprojzer0/packages/myproj-proxy/node_modules/.registry.npmjs.org/index-of-x/2.3.0/node_modules/index-of-x/index.js:27:21)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    at Module.load (internal/modules/cjs/loader.js:731:32)
    at Function.Module._load (internal/modules/cjs/loader.js:644:12)
    at Module.require (internal/modules/cjs/loader.js:771:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/Users/armenr/Desktop/myproj-new/myprojzer0/packages/myproj-proxy/node_modules/.registry.npmjs.org/inspect-x/1.9.1/node_modules/inspect-x/index.js:51:15)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
[nodemon] app crashed - waiting for file changes before starting...
armenr commented 5 years ago

@niftylettuce - Any chance you can throw us an assist? Else, we might have to find a different logger solution, and we love cabin :(

niftylettuce commented 5 years ago

I prob just need to replace that package with different solution, will try to find time today

armenr commented 5 years ago

Thanks Mr. Lettuce! @niftylettuce

If it helps at all, see this: - https://github.com/pnpm/pnpm/issues/1979

armenr commented 5 years ago

@niftylettuce - I may have been wrong in my assumption.

There's some kind of weirdness with the packages *-x packages being used - and their dependency graphs - but I was able to work around it.

I figure anyone using npm or yarn should be okay, but I'm done trying to figure it out specifically, as it is neither your problem, or mine. I use pnpm and --shamefully-flatten this to get it to work now...after removing some other dependencies I wasn't using in that particular microservice.

niftylettuce commented 5 years ago

@armenr Please try the latest Cabin version v5.0.0. I've upgraded its child dependency of Axe to v4.0.1 and optimized it a bit. You should no longer get any warnings about inspect-x or any other -x affixed packages as I've dropped that dependency util-format-x completely as it's not needed. Let me know if it works on your end after upgrading!

P.S. I had to do a major version bump because util-format-x allowed you to do util.format similar to Node in the browser (e.g. you could do %O format specifier). I switched util-format-x to use https://github.com/tmpfs/format-util instead, which is a way more lightweight and less complex alternative for the browser - and as such this was a major change (albeit probably nobody uses it for format specifiers in the browser since that's pretty much just a Node thing). At the least we can still use %s, %d, %%, and %j for now in the browser 😄

cc @zkochan

niftylettuce commented 5 years ago

For more insight into my "P.S." line above, see this section from the Axe docs:

You can also use format specifiers in the browser (uses format-util – has limited number of format specifiers) and Node (uses the built-in util.format method – supports all format specifiers). This feature is built-in thanks to smart detection using format-specifiers.