Next.js-是否可以调试getServerSideProps?
Hi as per docs是一项仅在服务器端执行的功能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 } } 因此,简单地删除调试器关键字是行不
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'下一个开发人员
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",
调试端口拥有后,您应该能够使用自己选择的端口