_os.platform is not a function. (In ‘_os.platform()’, ‘_os.platform’ is undefined) Solved

So I was running into this error _os.platform is not a function. (In ‘_os.platform()’, ‘_os.platform’ is undefined) and I didn’t know what I did to cause it until now.

I actually tried the suggestions that you see below that came with the error but that didn’t help.

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

In my attempt to troubleshoot I found many other posts[oldish] with this same issue left unsolved, so I decided to post up my solution to possibly help others.

In one of my components that I was working on somehow this import line —> **import { transform } from "typescript";** <---- was added. I suspect it was when I was adding the ‘transform’ style to a component but I probably hit the enter key on the wrong autocomplete option, thus importing this transform thing. Anyways removing this import line got rid of the error. So I would say make sure you don’t have any strange imports that you don’t recognize.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.