fetch-mock
fetch-mock copied to clipboard
"SyntaxError: Cannot use import statement outside a module" when importing fetchMock from fetch-mock
I am a newbee with fetch-mock, using jest for a React code, on typescript (targetting ESNext). I am getting the following error, which I do not understand:
/home/user/Documents/project/node_modules/node-fetch/src/index.js:9
import http from 'node:http';
^^^^^^
SyntaxError: Cannot use import statement outside a module
I have followed the advise for jest for typescript, using babel and so... but I cannot get this to work. Any idea on what might be wrong?
Seeing this exact same issue (only on JS code). Tried everything I can find online with no luck.
Hope this helps:
- https://github.com/node-fetch/node-fetch/issues/1588
- https://stackoverflow.com/questions/72706090/error-syntaxerror-cannot-use-import-statement-outside-a-module-when-using-nod?noredirect=1#comment128426614_72706090