Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@next/font error messages #42689

Merged
merged 1 commit into from Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/font/google/index.js
@@ -1,7 +1,15 @@
// 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)
8 changes: 8 additions & 0 deletions packages/font/local/index.js
@@ -1,7 +1,15 @@
// 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/local 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)
2 changes: 1 addition & 1 deletion packages/next/font/google/index.js
@@ -1,3 +1,3 @@
throw new Error(
'You tried to import `next/font/google`, did you mean `@next/font/google`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
'You tried to import `next/font/google`, did you mean `@next/font/google`?\nRead more: https://nextjs.org/docs/basic-features/font-optimization'
)
2 changes: 1 addition & 1 deletion packages/next/font/index.js
@@ -1,3 +1,3 @@
throw new Error(
'You tried to import `next/font`, did you mean `@next/font`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
'You tried to import `next/font`, did you mean `@next/font`?\nRead more: https://nextjs.org/docs/basic-features/font-optimization'
)
2 changes: 1 addition & 1 deletion packages/next/font/local/index.js
@@ -1,3 +1,3 @@
throw new Error(
'You tried to import `next/font/local`, did you mean `@next/font/local`?\nRead more: https://nextjs.org/docs/optimizing/fonts'
'You tried to import `next/font/local`, did you mean `@next/font/local`?\nRead more: https://nextjs.org/docs/basic-features/font-optimization'
)