// Validate next version
const semver = require('next/dist/compiled/semver')
if (semver.lt(require('next/package.json').version, '13.0.0')) {
throw new Error('`@next/font` is only available in Next.js 13 and newer.')
}
let message = '@next/font/google failed to run or is incorrectly configured.'
if (process.env.NODE_ENV === 'development') {
message +=
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
}
message += `\n\nRead more: https://nextjs.org/docs/basic-features/font-optimization`
throw new Error(message)
1条答案
按热度按时间y4ekin9u1#
编辑:这不起作用。下一步可能是在加载
@next/font/google
时使用require钩子来做一些webpack魔术,因为正常的导入似乎只是为了显示错误而存在:@next/font
不包括next
在它的package.json#peerDependencies
中。如果你使用pnpm并且没有在平坦模式下,那么next
将不会被找到。您可以使用www.example.com进行添加https://pnpm.io/package_json#pnpmpackageextensions
https://github.com/vercel/next.js/discussions/44498