今天,我从13.1.6升级到了next 13.3,并将我的Google字体迁移到了next/font/google
。然而,在Vercel上构建时,我遇到了一个错误。我已经通过运行npm run build
和npm run start
检查了生产构建中的更改,它工作正常,但在Vercel上失败了。
import { Inter } from "next/font/google"
const inter = Inter({
subsets: ["latin"],
variable: "--font-inter",
})
export default function MyApp({ Component, pageProps }) {
return (
<div className={`${inter.variable} font-sans`}>
{renderWithLayout(<Component {...pageProps} />)}
</div>
)
}
错误消息:
ReferenceError: AbortController is not defined
at fetchCSSFromGoogleFonts (/vercel/path0/node_modules/next/dist/compiled/@next/font/dist/google/fetch-css-from-google-fonts.js:34:28)
at nextFontGoogleFontLoader (/vercel/path0/node_modules/next/dist/compiled/@next/font/dist/google/loader.js:76:79)
at /vercel/path0/node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js:60:99
at Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:26)
at Object.nextFontLoader (/vercel/path0/node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js:13:31)
at LOADER_EXECUTION (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4134)
at runSyncOrAsync (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4145)
at iterateNormalLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5782)
at /vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5426
at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:395994
Failed to compile.
src/pages/_app.js
`next/font` error:
Failed to fetch `Inter` from Google Fonts.
> Build failed because of webpack errors
Error: Command "npm run build" exited with 1
Deployment completed
BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1
我在代码中没有使用AbortController
。
1条答案
按热度按时间whhtz7ly1#
暂时您可以降级到v13.2.3,它可以按预期工作。