JamesBrill / react-speech-recognition

💬Speech recognition for your React app
https://webspeechrecognition.com/
MIT License
657 stars 119 forks source link

Issue when used in nextjs project #88

Closed Nitzahon closed 3 years ago

Nitzahon commented 3 years ago

So the decision was made to move the site to nextjs to improve response time, and we've encountered the following error when trying to load a component that uses your package:

Server Error
ReferenceError: regeneratorRuntime is not defined

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///G:/Repositories/Biomarkerz/biosurveyfs/client/node_modules/react-speech-recognition/lib/RecognitionManager.js (168:61)
<unknown>
file:///G:/Repositories/Biomarkerz/biosurveyfs/client/node_modules/react-speech-recognition/lib/RecognitionManager.js (239:6)
Object.<anonymous>
file:///G:/Repositories/Biomarkerz/biosurveyfs/client/node_modules/react-speech-recognition/lib/RecognitionManager.js (334:2)

image

I'm hoping there is a simple fix for this. This package is fantastic and I loathe the thought of changing the implementation

Nitzahon commented 3 years ago

easier to read: [client] ReferenceError: regeneratorRuntime is not defined [client] at G:\Repositories\Biomarkerz\biosurveyfs\client\node_modules\react-speech-recognition\lib\RecognitionManager.js:201:61 [client] at G:\Repositories\Biomarkerz\biosurveyfs\client\node_modules\react-speech-recognition\lib\RecognitionManager.js:272:6 [client] at Object. (G:\Repositories\Biomarkerz\biosurveyfs\client\node_modules\react-speech-recognition\lib\RecognitionManager.js:367:2) [client] at Module._compile (internal/modules/cjs/loader.js:1015:30) [client] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10) [client] at Module.load (internal/modules/cjs/loader.js:879:32) [client] at Function.Module._load (internal/modules/cjs/loader.js:724:14) [client] at Module.require (internal/modules/cjs/loader.js:903:19) [client] at require (internal/modules/cjs/helpers.js:74:18) [client] at Object. (G:\Repositories\Biomarkerz\biosurveyfs\client\node_modules\react-speech-recognition\lib\SpeechRecognition.js:16:50) [client] at Module._compile (internal/modules/cjs/loader.js:1015:30) [client] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10) [client] at Module.load (internal/modules/cjs/loader.js:879:32) [client] at Function.Module._load (internal/modules/cjs/loader.js:724:14) [client] at Module.require (internal/modules/cjs/loader.js:903:19) [client] at require (internal/modules/cjs/helpers.js:74:18)

JamesBrill commented 3 years ago

Hi @Nitzahon Could you try the following:

If this works, I'll add this to the README as this seems to be a recurring problem for NextJS users.

Nitzahon commented 3 years ago

Legen....

Nitzahon commented 3 years ago

Wait for it.....

Nitzahon commented 3 years ago

DARY!

spiderpoul commented 3 years ago

Hi @Nitzahon Could you try the following:

  • npm i --save regenerator-runtime
  • Put this at the top of your _app.js file: import 'regenerator-runtime/runtime'

If this works, I'll add this to the README as this seems to be a recurring problem for NextJS users.

Worked for gatsby as well. Thanks!