Reputation: 41
Requiring unknown module "3". If you are sure the module exists, try restarting Metro. You may also want to run 'yarn' or 'npm intall'.
Any one can help me with this erro on react-native. I'm using vscode and android studio.
Upvotes: 4
Views: 9356
Reputation: 134
I encountered this problem after making major modifications to my imports, to resolve it, I just had to run the clean task
command to clean the builds artifacts , temp files and other generated files from mobile project and next time rebuild app
In root project directory , run this commands in terminal :
cd android
./gradlew clean command is used to execute clean task , which remove the build artifacts , temporary files and other generated files from the projects
./gradlew clean
After rebuild your project with Metro: npm start
Upvotes: 0
Reputation: 195
Error type 3
Error: Activity class {com.todoapp/com.todoapp.MainActivity} does not exist.
If you are facing this issue , you can follow this answer -
React-Native: Error type 3: Activity class does not exist
Upvotes: 0
Reputation: 167
Firstly, I encountered the same error message. Then I needed to solve the problem which occurred when I changed the folder structure, influences paths of imported files after I ran the app (on runtime). Actually the error message gives us the cause of the problem but I slogged on handling this error as a newbie on React Native. Frankly, the problem we have faced is about the packager as far as i have learnt.
It’s all about how the packager works. Packaging happens once before runtime so those variables don't have values yet.
Variables are components we have imported from other files in our situation.
The packager only works with statically analyzable “imports”. Treat “import” like a keyword.
As an example, let’s imagine you have folders in the root path of your project. If you run your Android Emulator, then packaging is carried through by Gradle under the hood.
import styles from './styles'
import StepCurrent from './images/stepcurrent.png'
import StepDone from './images/stepdone.png'
import StepNext from './images/stepnext.png'
Then if you try to change folder structure and call these components from another path, error occurs because packaging happened at the first phase, running the emulator, before your changes. Emulator does not read your current file paths.
import styles from './exampleFolder/styles'
import StepCurrent from './exampleFolder/images/stepcurrent.png'
import StepDone from './exampleFolder/images/stepdone.png'
import StepNext from './exampleFolder/images/stepnext.png'
So, you can restart your emulator to restart your packager. Then the problem disappears. References:
The packager only works with statically analyzable 'requires'.
Packaging happens once before runtime.
Solution way is to restart packager.
Upvotes: 2