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

Runtime issue (packed by esbuild): Cannot find module 'pino-pretty' #1164

Closed
Unga opened this issue Oct 17, 2021 · 7 comments · Fixed by #1209
Closed

Runtime issue (packed by esbuild): Cannot find module 'pino-pretty' #1164

Unga opened this issue Oct 17, 2021 · 7 comments · Fixed by #1209

Comments

@Unga
Copy link

Unga commented Oct 17, 2021

Hi,

I packed project with esbuild (output is one file index.js).
Configuration of Pino transport:
transport: { target: 'pino-pretty', options: { colorize: true, ignore: 'time,pid,hostname', }, },

On runtime I receive next error:
node:internal/modules/cjs/loader:930
throw err;
^
Error: Cannot find module 'pino-pretty'
Require stack:
/Users/d/test/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
at Function.resolve (node:internal/modules/cjs/helpers:99:19)
at fixTarget (/Users/d/test/index.js:36543:34)
at transport (/Users/d/test/index.js:36534:26)
at normalizeArgs (/Users/d/test/index.js:41495:20)
at Object.pino [as default] (/Users/d/test/index.js:42270:32)
...

Code (row 36543) from my packed index.js:
`
function fixTarget(origin) {

if (isAbsolute(origin) || origin.indexOf("file://") === 0) {
  return origin;
}

switch (origin) {
  case "pino/file":
    return join4(__dirname, "..", "file.js");
  default:
    return callerRequire.resolve(origin);   // row 36543
}

}`

Any ideas what to do? Thanks

@kibertoad
Copy link
Contributor

kibertoad commented Oct 17, 2021

Have you tried adding pino-pretty as a runtime dependency if you are using it?

@Unga
Copy link
Author

Unga commented Oct 17, 2021

Have you tried adding pino-pretty as a runtime dependency if you are using it?

Yep. Installed "npm i pino pino-pretty"

It looks like issue is not with dependencies but with import on the fly

@kibertoad
Copy link
Contributor

wonder if bundler is not picking it up due to dynamic import. can you somehow force dependency bundling?

@Unga
Copy link
Author

Unga commented Oct 17, 2021

wonder if bundler is not picking it up due to dynamic import. can you somehow force dependency bundling?

Yesterday I switched our project from Winston to Pino because Winston has same issue... I decided to try something new :) But when I added pino-pretty to config I got same issue.
What do you mean "force dependency bundling"?

@kibertoad
Copy link
Contributor

Check if esbuild supports manually specifying which dependencies to include.

@Unga
Copy link
Author

Unga commented Oct 18, 2021

Check if esbuild supports manually specifying which dependencies to include.

I want to bundle everything to one file. I don't want to setup anything as external dependencies
Did not find solution yet :(

@github-actions
Copy link

github-actions bot commented Feb 2, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants