Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@elastic/ecs-winston-format] Missing triple-beam dependency #108

Closed
rtritto opened this issue Nov 20, 2021 · 3 comments · Fixed by #155
Closed

[@elastic/ecs-winston-format] Missing triple-beam dependency #108

rtritto opened this issue Nov 20, 2021 · 3 comments · Fixed by #155
Labels
agent-nodejs Make available for APM Agents project planning. community triage

Comments

@rtritto
Copy link

rtritto commented Nov 20, 2021

loggers/winston/index.js file use triple-beam dependency that's not included in package.json dependencies:

...
const { MESSAGE } = require('triple-beam')
...

Steps to reproduce

  1. yarn init -y
  2. yarn set version berry
  3. yarn add @elastic/ecs-winston-format winston
  4. Create index.js file
const winston = require('winston')
const ecsFormat = require('@elastic/ecs-winston-format')

const logger = winston.createLogger({
  level: 'info',
  format: ecsFormat(),
  transports: [
    new winston.transports.Console()
  ]
})

logger.info('test1')
  1. yarn node index
C:\test-ecs-winston\.pnp.cjs:10188
    throw firstError;
    ^

Error: @elastic/ecs-winston-format tried to access triple-beam, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: triple-beam
Required by: @elastic/ecs-winston-format@npm:1.3.1 (via C:\test-ecs-winston\.yarn\cache\@elastic-ecs-winston-format-npm-1.3.1-8fc543f859-49a7767c64.zip\node_modules\@elastic\ecs-winston-format\)

Require stack:
- C:\test-ecs-winston\.yarn\cache\@elastic-ecs-winston-format-npm-1.3.1-8fc543f859-49a7767c64.zip\node_modules\@elastic\ecs-winston-format\index.js
- C:\test-ecs-winston\index.js
    at Function.external_module_.Module._resolveFilename (C:\test-ecs-winston\.pnp.cjs:10187:55)       
    at Function.external_module_.Module._load (C:\test-ecs-winston\.pnp.cjs:9986:48)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\test-ecs-winston\.yarn\cache\@elastic-ecs-winston-format-npm-1.3.1-8fc543f859-49a7767c64.zip\node_modules\@elastic\ecs-winston-format\index.js:20:21)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.external_module_.Module._load (C:\test-ecs-winston\.pnp.cjs:10036:14)
    at Module.require (internal/modules/cjs/loader.js:957:19)

Workaround

Add in .yarnrc.yml:

packageExtensions:
  '@elastic/ecs-winston-format@*':
    dependencies:
      triple-beam: '*'

Run yarn.

@github-actions github-actions bot added agent-nodejs Make available for APM Agents project planning. community triage labels Nov 20, 2021
@park78951
Copy link

resolved this?

@rtritto
Copy link
Author

rtritto commented Nov 10, 2022

No, it's still not fixed.

PS: I added a workaraund in initial comment.

@trentm
Copy link
Member

trentm commented Oct 18, 2023

Sorry all about not being on this. You are correct, of course.
This package has been relying on npm flat/hoisted install behaviour where installing winston would install triple-beam in a place where @elastic/ecs-winston-format could get it.

trentm added a commit that referenced this issue Oct 19, 2023
Document subtle diffs with our stringifier and winston.format.json().
Use a Format class to avoid needing a dep on winston or logform
for the 'winston.format(...)' call.

Closes: #108
@trentm trentm closed this as completed in efb11b7 Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning. community triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants