[英]Winston can't run project in WebStorm, but from command line and PM2 it works
I inherited a legacy project with Winston 2, and have a very strange behaviour.我用 Winston 2 继承了一个遗留项目,并且有一个非常奇怪的行为。 When I start the project with PM2 or by using node index.js
it works flawlessly.当我使用 PM2 或使用node index.js
启动项目时,它可以完美运行。 But when I define it as NODE.js configuration in WebStorm it exists with the following error:但是当我在 WebStorm 中将其定义为NODE.js配置时,它存在以下错误:
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: WebStorm 配置截图:
Installed version is Winston 2.2.0, and I restricted to it unfortunately.安装的版本是 Winston 2.2.0,不幸的是我限制了它。
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.当我更改它时,它开始工作,而不是这个定义的app.js
完整路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.