To resolve the issue of running Metro (the local dev server) from the wrong folder, follow the steps below:
- First, check if Metro is currently running. To do this, open your terminal/command prompt and execute the following command:
$ metro status
This will show the status of the Metro server. If it is already running, you should see a message similar to:
Metro Bundler is running.
If Metro is running, it’s recommended to stop it before proceeding to ensure a clean restart. Execute the following command to stop Metro:
$ metro stop
Once you have stopped Metro, navigate to the correct folder (your current project directory) where you want to run Metro from. For example:
$ cd /path/to/project
Finally, you can start Metro server for your current project by executing the following command within your project folder:
$ npx react-native start
This will run Metro with the default configuration for your React Native project. It will create and serve the necessary JavaScript bundle and manage the development dependencies.