NextJS 构建:类型错误:第一个参数必须是字符串类型或 Buffer、ArrayBuffer 或...类数组对象的实例。收到未定义

问题描述 投票:0回答:1

我正在尝试将 NextJS (v15.0.3) 应用程序部署到 Netlify。构建过程在“收集页面数据”步骤期间失败。每个页面都会产生以下错误:

2:25:13 PM: Error: Failed to collect configuration for /
2:25:13 PM:     at <unknown> (/opt/build/repo/node_modules/next/dist/build/utils.js:1131:23)
2:25:13 PM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:153:20) {
2:25:13 PM:   [cause]: TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
2:25:13 PM:       at 61978 (/opt/build/repo/.next/server/chunks/633.js:1:12040)
2:25:13 PM:       at t (/opt/build/repo/.next/server/webpack-runtime.js:1:143)
2:25:13 PM:       at 34908 (/opt/build/repo/.next/server/chunks/633.js:1:13151)
2:25:13 PM:       at t (/opt/build/repo/.next/server/webpack-runtime.js:1:143)
2:25:13 PM:       at 638 (/opt/build/repo/.next/server/chunks/633.js:1:8577)
2:25:13 PM:       at Function.t (/opt/build/repo/.next/server/webpack-runtime.js:1:143)
2:25:13 PM:       at async getLayoutOrPageModule (/opt/build/repo/node_modules/next/dist/server/lib/app-dir-module.js:33:15) {
2:25:13 PM:     code: 'ERR_INVALID_ARG_TYPE'
2:25:13 PM:   }
2:25:13 PM: }

这是一个示例页面,这是一个大部分空白的主页...

"use client"

import { Button } from "@/components/Button"

export default function AppPage() {
  const handleClick = () => {}

  return (
    <div className="max-w-5xl m-auto">
      <Button onClick={handleClick}>DO IT</Button>
    </div>
  )
}

next.js webpack
1个回答
0
投票

问题是 Netlify 上缺少环境变量。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.