gpt4 book ai didi

node.js - 我还应该使用什么来替代 nodejs 中的控制台?

转载 作者:搜寻专家 更新时间:2023-10-30 21:02:16 24 4
gpt4 key购买 nike

我正在使用 tslint:recommended 规则集编写一个 Node.js 应用程序,它会警告我在我的代码中使用 console.log:

src/index.ts[1, 1]: Calls to 'console.log' are not allowed.

我还应该使用什么?我应该使用某种等效的 system.out 吗?

这是我的 tslint.json:

{
"extends": "tslint:recommended"
}

最佳答案

它在 eslint doc 中说明关于 no-console 规则:

When Not To Use It

If you’re using Node.js, however, console is used to output information to the user and so is not strictly used for debugging purposes. If you are developing for Node.js then you most likely do not want this rule enabled.

因此偏离此处推荐的规则集是有效的,因此我调整了我的 tslint.json 以匹配:

{
"extends": "tslint:recommended",
"rules": {
"no-console": false
}
}

关于node.js - 我还应该使用什么来替代 nodejs 中的控制台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39769467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com