SyntaxError: Cannot use import statement outside a module #52
-
i am getting this error when trying to implement checkout pro in react specifically in nextjs. error : \node_modules@mercadopago\sdk-react\index.js:1 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hi @mrNotSenior Could you send us a sample from your code to help us understand what could be causing the error? |
Beta Was this translation helpful? Give feedback.
-
I'm getting this issue as well primarily because Jest can't handle ESM import, forcing us to transpile this SDK specifically. Is there a way u guys can distribute a cjs bundle as wel? |
Beta Was this translation helpful? Give feedback.
Hi @joaogabriels,
I thing that to render the Mercado Pago - React SDK we need to import it with Dynamic Import from NextJs, this enable the code to be ignored by the Server Side and only run on the Client Side.
Here is an example Wiki of a where it is possible to render the React SDK in NextJS, using the method
getPaymentMethods