Next.js-是否可以调试getServerSideProps?

Next.js-是否可以调试getServerSideProps?,next.js,Next.js,Hi as per docs是一项仅在服务器端执行的功能 export async function getServerSideProps(context) { console.log("hello world"); debugger; return { props: { age:55 }, // will be passed to the page component as props } } 因此,简单地删除调试器关键字是行不

Hi as per docs是一项仅在服务器端执行的功能

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——检查brk./node\u模块/next/dist/bin/next
  • 正在运行
    cross-env NODE_OPTIONS='--inspect'下一个开发人员
但是,console.log()和调试器关键字似乎都没有任何效果

但是,getServerSideProps中的我的道具被正确地传递,这证明函数被调用了

是否可以逐步完成getServerSideProps或至少让console.log正常工作?谢谢

附言


getServerSideProps外部的代码行是可调试的,并按预期工作。

为了使调试端口正确打开,您需要执行以下操作:

// package.json scripts
"dev": "NODE_OPTIONS='--inspect' next dev"
// if you want custom debug port on a custom server
"dev": "NODE_OPTIONS='--inspect=5009' node server.js",
调试端口拥有后,您应该能够使用自己选择的端口