'Error: Child Compilation failed - Module.createRequire is not a function

enter image description hereI have worked on a React/Typescript application on my Mac Machine, and zipped up the application (including node_modules) and emailed it to a colleague via Google Drive (Link). However, I was informed that this error (pictured above) occurred when attempting to run the application with 'npm install' and 'npm run start'. I have tried testing the application by sending the zipped app to my Windows machine and it seems to work fine.

My colleague is on a Linux/Ubuntu machine. I'm not very familiar with Linux, and not quite sure how to resolve this, and am open to suggestions.



Solution 1:[1]

Probably your colleague is running outdated version of node and npm. I guess that the project was created with create-react-app. If it's true, your colleague will need to have Node >= 14.0.0 and npm >= 5.6 on the machine.

Solution 2:[2]

when using a older version of node this error occured in my case(node version -10.16.0). So i upgraded my node version to 16.3.2 and tried.Then it worked prefectly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Delyan Keremedchiev
Solution 2 W.A.K.Jithmini