【发布时间】:2021-01-14 02:19:39
【问题描述】:
您好,根据文档getServerSideProps 是一个仅在服务器端执行的函数。
export async function getServerSideProps(context) {
console.log("hello world");
debugger;
return {
props: {
age:55
}, // will be passed to the page component as props
}
}
因此,简单地删除调试器关键字是行不通的。
我试过了:
- 在端口 9229 上附加 node.js 调试器
- 正在运行
node --inspect-brk ./node_modules/next/dist/bin/next - 正在运行
cross-env NODE_OPTIONS='--inspect' next dev
但是 console.log() 和 debugger 关键字似乎都没有任何效果。
但是我的 getServerSideProps 的 props 是正确传入的,这证明函数被调用了。
是否可以逐步执行 getServerSideProps 或至少让 console.log 工作?谢谢!
附言
getServerSideProps 之外的代码行是可调试的并且可以按预期工作。
【问题讨论】:
标签: next.js