'unable to determine transport target for "pino-pretty"
I am trying to use pino library but I am getting error
My code
I created a logger.js file and imported pino from node_module and added transport of pino-pretty.
logger.js
import pino from "pino";
const logger = pino({
transport: {
target: "pino-pretty",
options: {
colorize: true,
},
},
});
export default logger;
I created a database file and imported pino from logger file and used info function to display my error.
database.js
import mongoose from "mongoose";
import logger from "./logger";
const DB_CONNECTION_STRING =
process.env.DB_CONNECTION_STRING ||
"mongodb://localhost:27017/*******";
try {
await mongoose.connect(DB_CONNECTION_STRING);
logger.info("Connect to database");
} catch (e) {
logger.error(e, "Failed to connect to database. Goodbye");
process.exit(1);
}
Solution 1:[1]
pino-pretty could be missing from your package.json, have you tried adding it as a dependency?
Solution 2:[2]
If you don't have it installed you have to install pino-pretty
npm i pino-pretty
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jintao Koong |
| Solution 2 | Famara |

