我正在尝试使名为“ With Apollo Auth”的Next.js示例正常工作:https://github.com/zeit/next.js/tree/master/examples/with-apollo-auth
我已完成所有设置,但出现错误:
[INFO] Generating build script...
[INFO] Generating build script completed, took 321ms
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 10.4s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 698ms
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms
[INFO] Running build...
[SEVERE] json_serializable:json_serializable on lib/user.dart:
Invalid argument(s): Path must be absolute : dart:core
[SEVERE] json_serializable:json_serializable on lib/main.dart:
Invalid argument(s): Path must be absolute : dart:core
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Invalid argument(s): Path must be absolute : dart:core
[INFO] Running build completed, took 1.5s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 36ms
[SEVERE] Failed after 1.6s
此错误来自下一页,这是Next.js提供的样板代码:
TypeError: Cannot destructure property `req` of 'undefined' or 'null'.
const { AppTree, ctx: { req, res }} = ctx <----- Error line
我不确定为什么未定义ctx。
答案 0 :(得分:1)
您执行的销毁错误,请修复以下问题
const { AppTree, req, res } = ctx;