Node.js 是 crashing/exiting 缩小的 npm 包中没有任何错误消息,如何调试?
Node.js is crashing/exiting without any error message in minified npm package, how to debug?
我正在使用一个库 google-trends-api
并且由于某种原因它导致节点退出而没有任何错误。只是一个干净无误的出口。 try/catch 被忽略。我很困惑,因为这在我使用 node 的 3 年里从未发生过。
这是代码,不是很重要:
let res
try {
res = await googleTrends.interestOverTime({
keyword: ['something', keyword],
geo: 'EN',
startTime: new Date(getDaysAgoTimestamps(365)),
agent: proxyAgent
})
debug({res})
res = JSON.parse(res)
}
catch (e) {
debug('getTrendsAverages error')
debug(e)
}
我的问题是,我怎么才能开始调试呢?我试图查看节点模块中的库,但它被缩小了。
尝试添加以下错误处理函数,因为它们会提供有关您的问题的更多详细信息。
process.on('unhandledRejection', (reason, promise) => {
console.log(reason)
})
process.on('uncaughtException', (reason) => {
console.log(reason)
})
我正在使用一个库 google-trends-api
并且由于某种原因它导致节点退出而没有任何错误。只是一个干净无误的出口。 try/catch 被忽略。我很困惑,因为这在我使用 node 的 3 年里从未发生过。
这是代码,不是很重要:
let res
try {
res = await googleTrends.interestOverTime({
keyword: ['something', keyword],
geo: 'EN',
startTime: new Date(getDaysAgoTimestamps(365)),
agent: proxyAgent
})
debug({res})
res = JSON.parse(res)
}
catch (e) {
debug('getTrendsAverages error')
debug(e)
}
我的问题是,我怎么才能开始调试呢?我试图查看节点模块中的库,但它被缩小了。
尝试添加以下错误处理函数,因为它们会提供有关您的问题的更多详细信息。
process.on('unhandledRejection', (reason, promise) => {
console.log(reason)
})
process.on('uncaughtException', (reason) => {
console.log(reason)
})