buttons / react-github-btn

:octocat: Unofficial github:button component for React.js
https://buttons.github.io
BSD 2-Clause "Simplified" License
62 stars 8 forks source link

Cannot use import statement outside a module #10

Closed mzeeshanid closed 3 years ago

mzeeshanid commented 3 years ago

I used this component in my react website and it is working fine. I am migrating my site to next however, while using this component it gives the following error:

Screenshot 2021-03-12 at 8 05 34 PM

Steps to reproduce:

The strange thing is, it works with the following steps:

The moment I restart the server same error pops up again ;(

While searching about the error on stackoverflow I found that people suggesting to add type -> module in the package.json file however it does not resolve this issue. In this case I get internal server error.

Here is the video for reference:

https://user-images.githubusercontent.com/2767152/110960363-7b1ce880-8370-11eb-905d-c3ead7288ab7.mov

ntkme commented 3 years ago

You need to use next-transpile-modules to transpile ES module inside node_modules.

mzeeshanid commented 3 years ago

@ntkme thanks. If you can add some explanation it will be awesome :)

For anyone who is experiencing the similar issue follow the steps: