-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
Description
🔎 Search Terms
File Transport, Bun js, mkdirSync
The problem
File Transport does not work on Bun if dirName is not provided.
What version of Winston presents the issue?
3.17.0
What version of Node are you using?
bun v1.2.16
If this worked in a previous version of Winston, which was it?
No response
Minimum Working Example
import { createLogger, transports } from "winston";
export const logger = createLogger({
transports: [
new transports.File({
filename: "info.log",
level: "info",
}),
],
});
// This will never run on bun.
logger.info("Am I alive?");
While this run fine.
import { createLogger, transports } from "winston";
export const logger = createLogger({
transports: [
new transports.File({
filename: "info.log",
level: "info",
dirname: 'apilog' // THIS IS REQUIRED TO OVERCOME the bun error.
}),
],
});
// This now run fine.
logger.info("Am I alive?");
Additional information
The error is
756 | _createLogDirIfNotExist(dirPath) {
757 | /* eslint-disable no-sync */
758 | if (!fs.existsSync(dirPath)) {
759 | fs.mkdirSync(dirPath, { recursive: true });
^
ENOENT: no such file or directory, mkdir
syscall: "mkdir",
errno: -2,
code: "ENOENT"
at _createLogDirIfNotExist (C:\Users\vanta\code\bun-test2\node_modules\winston\lib\winston\transports\file.js:759:10)
at new File (C:\Users\vanta\code\bun-test2\node_modules\winston\lib\winston\transports\file.js:94:28)
at C:\Users\vanta\code\bun-test2\index.ts:10:5
Related: oven-sh/bun#19090