Open danielbakas opened 1 year ago
Hi @danielbakas, I also encountered with the error "Cannot use import statement outside a module" but in my case it's due to axios
. Here is my resolution, I hope it can help you: https://stackoverflow.com/questions/75523632/cannot-use-import-statement-outside-a-module-with-axios-in-react/76458512#76458512
Describe the bug
When trying to import ForceGraph3D from
react-force-graph
by vasturiano in a create-react-app project, the tests fail with a SyntaxError: "Cannot use import statement outside a module". The error points to the first line ofreact-force-graph.mjs
file.Did you try recovering your dependencies?
Yes, I tried recovering my dependencies but the issue still persists.
Which terms did you search for in User Guide?
I searched for terms like "Jest encountered an unexpected token", "Cannot use import statement outside a module", "react-force-graph test fails".
Environment
Steps to reproduce
Expected behavior
Tests run successfully without any import errors.
Actual behavior
Tests fail with SyntaxError: "Cannot use import statement outside a module". The error points to the first line of
react-force-graph.mjs
file.