reactjs 错误:找不到模块“txtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtx”

icomxhvb  于 2023-01-05  发布在  React
关注(0)|答案(1)|浏览(117)

我正在尝试运行一个程序使用react,但我面临这个问题,我检查并尝试了许多解决方案,没有一个工作。任何帮助是高度赞赏enter image description here
我试过很多方法都没用

y4ekin9u

y4ekin9u1#

编辑:这不起作用。下一步可能是在加载@next/font/google时使用require钩子来做一些webpack魔术,因为正常的导入似乎只是为了显示错误而存在:

// 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)

@next/font不包括next在它的package.json#peerDependencies中。如果你使用pnpm并且没有在平坦模式下,那么next将不会被找到。
您可以使用www.example.com进行添加https://pnpm.io/package_json#pnpmpackageextensions

"packageExtensions": {
      "@next/font": {
        "peerDependencies": {
          "next": "*"
        }
      },
  • /页码/索引.tsx*
import { Inter } from '@next/font/google'
  • /节点模块/@next/字体/谷歌/索引.js*
const semver = require('next/dist/compiled/semver')

https://github.com/vercel/next.js/discussions/44498

相关问题