"Unable to resolve module path" in React Native
The error message:
Unable to resolve module path
Should really be:
Unable to resolve module "path"
path
is the name of the module it can't load! I was reading the error message as "can't resolve a path to the module".
So the root cause is, the file it lists in the error message is importing the native Node module path
, which isn't available on React Native.
The solution is to npm install -D path
, which is a replica implementation.
Any imports from @babel/core
package is causing this error.
Some code editors are inserting the import line automatically.
For example, import { types } from '@babel/core'
is inserted by Visual Studio Code when you enter types
.
If you remove the imports from @babel/core
in the codes, it will be fixed.
Quote from chronikum on react-native github issues for future readers
Just check if you somewhere accidentally imported something from @babel/core.
Here is the original link
https://github.com/facebook/react-native/issues/27522#issuecomment-568306279