当使用console.log()时,表情符号会在终端中呈现,但当使用logger.info()、logger.warn()等表情符号时,表情符号不会正确呈现。我用的是皮诺切特
src/app.jsutils/logger.js
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");
});
--终端输出--[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
我期待相关的🚀表情符号,但它显示像≡
1条答案
按热度按时间8fsztsew1#
您必须将“chcp 65001”添加到package.json中的脚本标记中。
"scripts": { "start": "chcp 65001 && nodemon --exec file-path" }