pino icon indicating copy to clipboard operation
pino copied to clipboard

Module not found: Error: Can't resolve 'pino-pretty' in

Open uwajacques opened this issue 6 years ago • 11 comments

I seem to be getting Module not found: Error: Can't resolve 'pino-pretty' warnings even though prettyPrint is set to false. Is there anyway to turn them off?

uwajacques avatar Aug 01 '19 14:08 uwajacques

Can you paste a full stack trace?

mcollina avatar Aug 01 '19 16:08 mcollina

@uwajacques did you manage to resolve this?

davidmarkclements avatar Sep 14 '19 17:09 davidmarkclements

Have just bumping into this with rollup setup, in such case, one need to settreeshake.moduleSideEffects to false, hope this helps.

imcotton avatar Dec 12 '19 06:12 imcotton

It is caused by this line: https://github.com/pinojs/pino/blob/master/lib/tools.js#L159

Perhaps it should just be a dependency?

Webpack warning is:

WARNING in /Users/user/project/node_modules/pino/lib/tools.js
Module not found: Error: Can't resolve 'pino-pretty' in '/Users/user/project/node_modules/pino/lib'
 @ /Users/user/project/node_modules/pino/lib/tools.js
 @ /Users/user/project/node_modules/pino/pino.js
 @ ./src/lib/logger.js
...

mattyod avatar Dec 12 '19 14:12 mattyod

Oh, forgot to mention, in rollup setup you need to exclude pino-pretty as well, like below

{

    treeshake: {
        moduleSideEffects: false,
    },

    plugins: [
        commonjs({
            exclude: [
                'node_modules/pino-pretty/**',
            ],
        }),
    ],

}

Webpack might need something similar as well.

imcotton avatar Dec 12 '19 15:12 imcotton

Perhaps it should just be a dependency?

https://github.com/pinojs/pino/pull/699

jsumners avatar Dec 12 '19 16:12 jsumners

For those arriving here looking for a rollup solution…

          {
            plugins: [
              resolve(),
              commonjs({
                ignore: ['pino-pretty'],
              }),
            ],
          }

Just make sure to never set pino prettyPrint to true at runtime :)

moeriki avatar Jan 24 '20 17:01 moeriki

In webpack, you can use the externals option:

module.exports = {
  // ...
  externals: ['pino-pretty'],
};

bdchauvette avatar Jun 02 '20 19:06 bdchauvette

Does anyone want to send a PR to document this?

davidmarkclements avatar Jul 10 '20 15:07 davidmarkclements