Error: Failed to collect page data for / at /usr/local/lib/node_modules/next/dist/build/utils.js:1179:15 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { type: 'Error' } #65070
Unanswered
SimplicitySpace
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Ive been using next.js to for my project but i keep getting error when i try to run 'next build' to get HTML/CSS/JS file so i can deploy.
The issues i keep running into are:
Collecting page data ..TypeError: Cannot read properties of undefined (reading 'ReactJsxRuntime')
at 9385 (/Users/mac/Documents/ReactProjects/TicketDanfoTest/danfo/.next/server/chunks/355.js:1:81505)
at webpack_require (/Users/mac/Documents/ReactProjects/TicketDanfoTest/danfo/.next/server/webpack-runtime.js:1:145)
at 6240 (/Users/mac/Documents/ReactProjects/TicketDanfoTest/danfo/.next/server/chunks/119.js:1:430)
at Function.webpack_require (/Users/mac/Documents/ReactProjects/TicketDanfoTest/danfo/.next/server/webpack-runtime.js:1:145)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async collectGenerateParams (/usr/local/lib/node_modules/next/dist/build/utils.js:858:17)
at async /usr/local/lib/node_modules/next/dist/build/utils.js:1074:17
at async Span.traceAsyncFn (/usr/local/lib/node_modules/next/dist/trace/trace.js:105:20)
// Navigating to /usr/local/lib/node_modules/next/dist/build/utils.js:1179:15. Then i found this function
async function isPageStatic({ page, distDir, configFileName, runtimeEnvConfig, httpAgentOptions, locales, defaultLocale, parentId, pageRuntime, edgeInfo, pageType, originalAppPath, isrFlushToDisk, maxMemoryCacheSize, incrementalCacheHandlerPath }) {
const isPageStaticSpan = (0, _trace.trace)("is-page-static-utils", parentId);
return isPageStaticSpan.traceAsyncFn(async ()=>{
require("../shared/lib/runtime-config.external").setConfig(runtimeEnvConfig);
(0, _setuphttpagentenv.setHttpClientAndAgentOptions)({
httpAgentOptions
});
let componentsResult;
let prerenderRoutes;
let encodedPrerenderRoutes;
let prerenderFallback;
let appConfig = {};
let isClientComponent = false;
const pathIsEdgeRuntime = (0, _isedgeruntime.isEdgeRuntime)(pageRuntime);
if (pathIsEdgeRuntime) {
const runtime = await (0, _sandbox.getRuntimeContext)({
paths: edgeInfo.files.map((file)=>_path.default.join(distDir, file)),
edgeFunctionEntry: {
...edgeInfo,
wasm: (edgeInfo.wasm ?? []).map((binding)=>({
...binding,
filePath: _path.default.join(distDir, binding.filePath)
}))
},
name: edgeInfo.name,
useCache: true,
distDir
});
const mod = runtime.context._ENTRIES[
middleware_${edgeInfo.name}
].ComponentMod;isClientComponent = (0, _clientreference.isClientReference)(mod);
componentsResult = {
Component: mod.default,
ComponentMod: mod,
pageConfig: mod.config || {},
// @ts-expect-error this is not needed during require
buildManifest: {},
reactLoadableManifest: {},
getServerSideProps: mod.getServerSideProps,
getStaticPaths: mod.getStaticPaths,
getStaticProps: mod.getStaticProps
};
} else {
componentsResult = await (0, _loadcomponents.loadComponents)({
distDir,
page: originalAppPath || page,
isAppPath: pageType === "app"
});
}
const Comp = componentsResult.Component || {};
let staticPathsResult;
if (pageType === "app") {
isClientComponent = (0, _clientreference.isClientReference)(componentsResult.ComponentMod);
const tree = componentsResult.ComponentMod.tree;
const staticGenerationAsyncStorage = componentsResult.ComponentMod.staticGenerationAsyncStorage;
if (!staticGenerationAsyncStorage) {
throw new Error("Invariant: staticGenerationAsyncStorage should be defined on the module");
}
const serverHooks = componentsResult.ComponentMod.serverHooks;
if (!serverHooks) {
throw new Error("Invariant: serverHooks should be defined on the module");
}
const { routeModule } = componentsResult;
const generateParams = routeModule && AppRouteRouteModule.is(routeModule) ? [
{
config: {
revalidate: routeModule.userland.revalidate,
dynamic: routeModule.userland.dynamic,
dynamicParams: routeModule.userland.dynamicParams
},
generateStaticParams: routeModule.userland.generateStaticParams,
segmentPath: page
}
] : await collectGenerateParams(tree);
appConfig = generateParams.reduce((builtConfig, curGenParams)=>{
const { dynamic, fetchCache, preferredRegion, revalidate: curRevalidate } = (curGenParams == null ? void 0 : curGenParams.config) || {};
// TODO: should conflicting configs here throw an error
// e.g. if layout defines one region but page defines another
if (typeof builtConfig.preferredRegion === "undefined") {
builtConfig.preferredRegion = preferredRegion;
}
if (typeof builtConfig.dynamic === "undefined") {
builtConfig.dynamic = dynamic;
}
if (typeof builtConfig.fetchCache === "undefined") {
builtConfig.fetchCache = fetchCache;
}
// any revalidate number overrides false
// shorter revalidate overrides longer (initially)
if (typeof builtConfig.revalidate === "undefined") {
builtConfig.revalidate = curRevalidate;
}
if (typeof curRevalidate === "number" && (typeof builtConfig.revalidate !== "number" || curRevalidate < builtConfig.revalidate)) {
builtConfig.revalidate = curRevalidate;
}
return builtConfig;
}, {});
if (appConfig.dynamic === "force-static" && pathIsEdgeRuntime) {
_log.warn(
Page "${page}" is using runtime = 'edge' which is currently incompatible with dynamic = 'force-static'. Please remove either "runtime" or "force-static" for correct behavior
);}
if (appConfig.dynamic === "force-dynamic") {
appConfig.revalidate = 0;
}
if ((0, _isdynamic.isDynamicRoute)(page)) {
({ paths: prerenderRoutes, fallback: prerenderFallback, encodedPaths: encodedPrerenderRoutes } = await buildAppStaticPaths({
page,
serverHooks,
staticGenerationAsyncStorage,
configFileName,
generateParams,
distDir,
requestHeaders: {},
isrFlushToDisk,
maxMemoryCacheSize,
incrementalCacheHandlerPath
}));
}
} else {
if (!Comp || !(0, _reactis.isValidElementType)(Comp) || typeof Comp === "string") {
throw new Error("INVALID_DEFAULT_EXPORT");
}
}
const hasGetInitialProps = !!Comp.getInitialProps;
const hasStaticProps = !!componentsResult.getStaticProps;
const hasStaticPaths = !!componentsResult.getStaticPaths;
const hasServerProps = !!componentsResult.getServerSideProps;
// A page cannot be prerendered and define a data requirement. That's
// contradictory!
if (hasGetInitialProps && hasStaticProps) {
throw new Error(_constants.SSG_GET_INITIAL_PROPS_CONFLICT);
}
if (hasGetInitialProps && hasServerProps) {
throw new Error(_constants.SERVER_PROPS_GET_INIT_PROPS_CONFLICT);
}
if (hasStaticProps && hasServerProps) {
throw new Error(_constants.SERVER_PROPS_SSG_CONFLICT);
}
const pageIsDynamic = (0, _isdynamic.isDynamicRoute)(page);
// A page cannot have static parameters if it is not a dynamic page.
if (hasStaticProps && hasStaticPaths && !pageIsDynamic) {
throw new Error(
getStaticPaths can only be used with dynamic pages, not '${page}'.
+\nLearn more: https://nextjs.org/docs/routing/dynamic-routes
);}
if (hasStaticProps && pageIsDynamic && !hasStaticPaths) {
throw new Error(
getStaticPaths is required for dynamic SSG pages and is missing for '${page}'.
+\nRead more: https://nextjs.org/docs/messages/invalid-getstaticpaths-value
);}
if (hasStaticProps && hasStaticPaths || staticPathsResult) {
({ paths: prerenderRoutes, fallback: prerenderFallback, encodedPaths: encodedPrerenderRoutes } = await buildStaticPaths({
page,
locales,
defaultLocale,
configFileName,
staticPathsResult,
getStaticPaths: componentsResult.getStaticPaths
}));
}
const isNextImageImported = globalThis.__NEXT_IMAGE_IMPORTED;
const config = isClientComponent ? {} : componentsResult.pageConfig;
if (config.unstable_includeFiles || config.unstable_excludeFiles) {
_log.warn(
unstable_includeFiles/unstable_excludeFiles has been removed in favor of the option in next.config.js.\nSee more info here: https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
);}
return {
isStatic: !hasStaticProps && !hasGetInitialProps && !hasServerProps,
isHybridAmp: config.amp === "hybrid",
isAmpOnly: config.amp === true,
prerenderRoutes,
prerenderFallback,
encodedPrerenderRoutes,
hasStaticProps,
hasServerProps,
isNextImageImported,
appConfig
};
}).catch((err)=>{
if (err.message === "INVALID_DEFAULT_EXPORT") {
throw err;
}
console.error(err);
}
I went ahead to try and recreate a new project, i ran into same issue
![image](https://private-user-images.githubusercontent.com/117374307/325861195-b806f8b2-4e46-4c6a-bd0e-2115eef75f8c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzMzk5MTcsIm5iZiI6MTcyMjMzOTYxNywicGF0aCI6Ii8xMTczNzQzMDcvMzI1ODYxMTk1LWI4MDZmOGIyLTRlNDYtNGM2YS1iZDBlLTIxMTVlZWY3NWY4Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDczMFQxMTQwMTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hMjAxMzA3MzVhM2Q4ZGYzMjEzNjZhMGUwMGNlOGRjOTIzZjkzYmEyNzUwMjU5Y2I4YjcyOTRiM2E3NDI4NjlhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.0evpuTHwtZzWPxIqcl-IM0hPWG-4Mp0hIuFIhTEFxcA)
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions