I inherited a legacy project with Winston 2, and have a very strange behaviour. When I start the project with PM2 or by using node index.js
it works flawlessly. But when I define it as NODE.js configuration in WebStorm it exists with the following error:
Error: ENOENT: no such file or directory, open 'logs/info-log.log'
Emitted 'error' event on instance at:
at WriteStream.<anonymous> (/legacy-project/node_modules/winston/lib/winston/transports/file.js:491:16)
at WriteStream.emit (events.js:310:20)
at WriteStream.EventEmitter.emit (domain.js:482:12)
at internal/fs/streams.js:321:12
at FSReqCallback.oncomplete (fs.js:155:23) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'logs/info-log.log'
}
There is config for file transport:
{
"category": "default",
"name": "info-log",
"filename": "logs/info-log.log",
"level": "info"
}
Screenshot of WebStorm config:
Installed version is Winston 2.2.0, and I restricted to it unfortunately.
Ok, the issue was related to the working directory. There're a few apps which nested under the same working directory, which considered to be a root of the project. My mistake was that I defined the working directory as nested path of the sub-project. When I changed it, and instead of this defined full path to app.js
, it began to work.