When using the console.log() the emojis are rendered in the terminal but when using logger.info() , logger.warn() , etc emojis didn't appropriately render. I used Pino-pretty.
import express from "express";
import cors from "cors";
import logger from "./utils/logger";
import "dotenv/config";
const app = express();
const PORT = process.env.PORT || "8090";
app.use(cors());
app.use(express.json({
limit: "20mb"
}));
app.get("/", (req, res, next) => {
res.send("<h2> Library Management System API</h2>");
next();
});
app.listen(PORT, () => {
console.log(`Listening on PORT ${PORT}`);
logger.info(`Listening on PORT ${PORT} `);
logger.info("This is testing");
logger.error("This is error");
logger.warn("This is warning");
});
--Output in the terminal--
[nodemon] restarting due to changes...
[nodemon] starting babel-node src/app.js
Listening on PORT 8090
[24-02-2023 14:37:41] INFO: **🚀**Listening on PORT 8090
[24-02-2023 14:37:41] INFO: This is testing
[24-02-2023 14:37:41] ERROR: This is error
[24-02-2023 14:37:41] WARN: This is warning
I expected the relevant emoji but it showed like 🚀
You have to add "chcp 65001" to your script tag in package.json.
"scripts": { "start": "chcp 65001 && nodemon --exec file-path" }