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

import error #3

Closed
sushilbansal opened this issue Mar 1, 2021 · 5 comments
Closed

import error #3

sushilbansal opened this issue Mar 1, 2021 · 5 comments

Comments

@sushilbansal
Copy link

sushilbansal commented Mar 1, 2021

"react-hook-speech-to-text": "^0.4.0",

I copied the sample code into my nextjs repo and tried to run it. Got the following error:

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1172:16)
at Module._compile (internal/modules/cjs/loader.js:1220:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32)
at Function.Module._load (internal/modules/cjs/loader.js:967:14)
at Module.require (internal/modules/cjs/loader.js:1145:19)
at require (internal/modules/cjs/helpers.js:75:18)
at eval (webpack-internal:///react-hook-speech-to-text:1:18)
at Object.react-hook-speech-to-text (/Users/sushilbansal/Documents/projects/kami/kami-next/.next/server/pages/join-chat.js:161:1)
at webpack_require (/Users/sushilbansal/Documents/projects/kami/kami-next/.next/server/pages/join-chat.js:23:31)
at eval (webpack-internal:///./web/modules/videoChat/Transcript.tsx:7:83)
at Module../web/modules/videoChat/Transcript.tsx (/Users/sushilbansal/Documents/projects/kami/kami-next/.next/server/pages/join-chat.js:128:1)
at webpack_require (/Users/sushilbansal/Documents/projects/kami/kami-next/.next/server/pages/join-chat.js:23:31)
at eval (webpack-internal:///./web/modules/videoChat/PeerChat.tsx:13:69)
at Module../web/modules/videoChat/PeerChat.tsx (/Users/sushilbansal/Documents/projects/kami/kami-next/.next/server/pages/join-chat.js:116:1)
at webpack_require (/Users/sushilbansal/Documents/projects/kami/kami-next/.next/server/pages/join-chat.js:23:31)

@sushilbansal
Copy link
Author

@Riley-Brown can you please check. Anything you can do to help will be greatly appreciated.

@ilhamwahabi
Copy link

Hi! I'm also using this in my Next.js project

In my exploration looks like Next.js still have an issue for ES module vercel/next.js#9607
Which this package exported ESModule

this is how is solve it

  1. npm i next-transpile-modules

  2. In next.config.js

const withTM = require('next-transpile-modules')(['react-hook-speech-to-text'])

module.exports = withTM({
  // your config, if any
})

@sushilbansal
Copy link
Author

will give it a try. Thanks.

@notiles
Copy link

notiles commented Jul 9, 2021

Hello did you succeed to use this package in a Next.js project ?

@28development
Copy link

I have the same issue even after doing

const withTM = require('next-transpile-modules')(['react-hook-speech-to-text'])

module.exports = withTM({
  // your config, if any
})

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants