You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Next.js 15后执行bun run build时构建失败求助

Next.js 15 构建失败问题求助

我最近将项目升级至Next.js 15,本地开发环境一切正常,但执行bun run build构建命令时出现错误。错误信息截图如下:
构建错误截图

当前项目代码(app/(single-page)/tags/[tag]/page.tsx)

import { getBlogPosts } from "@/app/db/posts";
import { Tag } from "@/components/tag";
import { nonAccentVietnamese } from "@/lib/non-accent-vietnamese";
import { getAllTags, getPostsByTagSlug, sortTagsByCount } from "@/lib/tags";
import { Metadata } from "next";
import WritingList from "@/components/writing-list";
import { getItemsByYear } from "@/lib/utils";
import PageHeader from "@/components/page-header";

interface TagPageProps {
  params: {
    tag: string;
  };
}

export async function generateMetadata({
  params,
}: TagPageProps): Promise<Metadata> {
  const { tag } = params;
  const siteUrl = `/tags/${tag}`;
  const seoTitle = `Topic "${tag}"`
  const seoDescription = `Posts on the topic of ${tag}`

  return {
    title: seoTitle,
    description: seoDescription,
    keywords: [
      seoTitle,
      seoDescription
    ],
    openGraph: {
      title: seoTitle,
      description: seoDescription,
      url: siteUrl,
      images: siteUrl + "/og.png",
    },
    alternates: {
      canonical: siteUrl,
    },
  };
}

export const generateStaticParams = async () => {
  const posts = await getBlogPosts();
  const tags = getAllTags(posts);
  const paths = Object.keys(tags).map((tag) => ({ tag: nonAccentVietnamese(tag) }));
  return paths;
};

export default function TagPage({ params }: TagPageProps) {
  const { tag } = params;
  const title = tag.split("-").join(" ");
  const posts = getBlogPosts();
  const allPosts = getPostsByTagSlug(posts, tag);
  const displayPosts = allPosts.filter(post => post.metadata.publishedAt);
  const tags = getAllTags(posts);
  const sortedTags = sortTagsByCount(tags);

  const itemsByYear = getItemsByYear(displayPosts);
  const years = Object.keys(itemsByYear).map(Number).sort(
    (a, b) => b - a,
  );

  return (
    <section>
      <PageHeader
        title={`Topic: ${title}`}
        description={`Posts on the topic of ${tag}`}
      />
        <div className="mb-8 flex flex-wrap gap-2">
          {sortedTags?.map((t, index) => (
            <Tag tag={t} key={index} count={tags[t]} current={nonAccentVietnamese(t) === tag} />
          ))}
        </div>
        {displayPosts?.length > 0 ? (
          <WritingList
            getItemsByYear={itemsByYear}
            years={years}
            url="blog"
          />
        ) : (
          <p>No posts available for the tag <strong>{title}</strong>.</p>
        )
      }
    </section>
  );
}

项目目录结构

...
  app
   |__(single-page)
          |__tags
               |__[tag]
                    |__page.tsx
       
  components
  ...

已尝试的解决方法

  • 验证所有依赖与Next.js 15兼容
  • 查阅Next.js 15发布说明中的破坏性变更
  • 执行bun install确保所有包正确安装

目前问题仍未解决,希望能得到问题原因分析及解决方案建议,如需更多信息可随时提供。谢谢!

内容的提问来源于stack exchange,提问作者Alexander VT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 19:32:25