pino
pino copied to clipboard
Module not found: Error: Can't resolve 'pino-pretty' in
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?
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?