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

Created on 1 Aug 2019  Â·  9Comments  Â·  Source: pinojs/pino

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?

documentation good first issue

Most helpful comment

In webpack, you can use the externals option:

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

All 9 comments

Can you paste a full stack trace?

@uwajacques did you manage to resolve this?

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

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

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.

Perhaps it should just be a dependency?

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

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 :)

In webpack, you can use the externals option:

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

Does anyone want to send a PR to document this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lioaslan picture lioaslan  Â·  3Comments

ronag picture ronag  Â·  5Comments

P4sca1 picture P4sca1  Â·  4Comments

mcollina picture mcollina  Â·  6Comments

NicolaiSchmid picture NicolaiSchmid  Â·  4Comments