由于错误“导出在以下路径上遇到错误:”而导致构建失败

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

当我尝试在本地和 Vercel 上构建项目时遇到错误。构建失败并出现以下错误:

**错误**

Export encountered errors on following paths: /(dashboard)/dashboard/edit-resume/page: /dashboard/edit-resume error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

如果我注释掉 useSearchParams 部分,则构建成功完成。

我也尝试过使用 Suspense,如下所示,但它没有解决问题:

我的代码

该错误似乎与

useSearchParams
中的
next/navigation
有关。这是有问题的代码片段:

`import { useSearchParams } from "next/navigation";

const router = useRouter();
const searchParams = useSearchParams();
const search = searchParams.get("template");
console.log("queryParams", search);
`

`return (
    <Suspense fallback={<Loader size="lg" />}>
        <div className="flex flex-col md:flex-row">
            // other codes
        </div>
    </Suspense>
);
`

I have searched stack overflow and github issues cannot find any solution, can anyone help me?
reactjs next.js build
1个回答
0
投票

最后,解决了这个问题,我在组件级别给出了悬念,但它应该位于我的组件的父级,它是loading.tsx组件,因为我在next.js 14中使用应用程序路由器。 谢谢大家。

© www.soinside.com 2019 - 2024. All rights reserved.