You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js13使用react-speech-recognition遇regeneratorRuntime未定义错误求助

Next.js 13 + Redux Toolkit 中遇到 ReferenceError: regeneratorRuntime is not defined 错误求助

我在Next.js 13项目中搭配Redux Toolkit开发,现在遇到了ReferenceError: regeneratorRuntime is not defined错误。项目代码位于nextjsfrontend分支,我是Web开发新手,希望能得到解决帮助。

我已经按照react-speech-recognition的官方文档指引,执行了npm install regenerator-runtime并在_app.js中导入,但错误仍然存在。

触发错误的SpeechRecognitionComponent文件代码

import React from 'react'
import SpeechRecognition, {useSpeechRecognition} from "react-speech-recognition"

function SpeechRecognitionComponent() {
  const {
    transcript,
    interimTranscript,
    finalTranscript,
    resetTranscript,
    listening,
  } = useSpeechRecognition();

  if (!browserSupportsSpeechRecognition) {
    return <span>Browser doesn't support speech recognition.</span>;
  }

  return (
    <>
      <div>
        <p>Microphone: {listening ? 'on' : 'off'}</p>
        <button onClick={SpeechRecognition.startListening}>Start</button>
        <button onClick={SpeechRecognition.stopListening}>Stop</button>
        <button onClick={resetTranscript}>Reset</button>
        <p>{transcript}</p>
      </div>
    </>
  )
}

export default SpeechRecognitionComponent

layout.js文件代码

import './globals.css'

import { Providers } from "@/redux/provider";

export const metadata = {
  title: 'Leo GPT',
  description: 'An AI that immitates me',
}

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <Providers>
          <header>
            <h2>Leo GPT</h2>
          </header>
        {children}
        </Providers>
      </body>
    </html>
  )
}

_app.js文件代码

import 'regenerator-runtime/runtime'

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />;
}

内容的提问来源于stack exchange,提问作者Leotheperegrine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 00:14:59