HLB
HLB

Reputation: 558

Unable to resolve empty-module.js react-native and metro-cli

I've switched over from a windows dev environment to a linux environment and I'm having trouble getting react-native app going again. The application builds with gradle and installs onto the phone through adb perfectly, when I send the app build through metro (npx react-native start) I get the following spit back. The package exists... so I don't understand how its not found. I thing I don't understand is why from /home/hovaness/Public/ignitefolderscan/_ returns when its not a realy directory in the first place...

Error

error: Error: Unable to resolve module /home/hovaness/Public/ignitefolderscan/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-runtime/src/modules/empty-module.js from /home/hovaness/Public/ignitefolderscan/_: /home/hovaness/Public/ignitefolderscan/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-runtime/src/modules/empty-module.js could not be found within the project or in these directories: node_modules

Ignite-cli doctor

System
  platform           linux                                                        
  arch               x64                                                          
  cpu                20 cores           Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz
  directory          ignitefolderscan   /home/hovaness/Public/ignitefolderscan    

JavaScript (and globally-installed packages)
  node                            16.14.2                                   /bin/node                                                    
  npm                             8.7.0                                     /home/hovaness/Public/ignitefolderscan/node_modules/.bin/npm
    @react-native-community/cli   7.0.3                                                                                                  
    corepack                      0.10.0                                                                                                
    expo                          44.0.6                                                                                                
    jetifier                      2.0.0                                                                                                  
    n                             8.1.0                                                                                                  
    npm                           8.7.0                                                                                                  
    npx                           10.2.2                                                                                                
    pnpm                          7.0.0-rc.6                                                                                            
    react-native-cli              2.0.1                                                                                                  
    yarn                          1.22.18                                                                                                
  yarn                            1.22.18                                   /bin/yarn                                                    
  pnpm                            7.0.0-rc.6                                /bin/pnpm                                                    
                                  <no pnpm global package info available>                                                                

Ignite
  ignite-cli         7.10.8       /home/hovaness/.npm/_npx/e31027f3785124a8/node_modules/.bin/ignite      
  ignite src         build        /home/hovaness/.npm/_npx/e31027f3785124a8/node_modules/ignite-cli/build

Android
  java               11.0.14.1    /bin/java
  android home       -            undefined

Upvotes: 5

Views: 3473

Answers (2)

Jecrs687
Jecrs687

Reputation: 136

I had the same issue, to fix that I did:

  • remove the node_modules folder
  • remove yarn.lock or package-lock.json
  • Run command: npm install --force

if it does not work, try also:

  • npm install --legacy-peer-deps

Upvotes: 0

HLB
HLB

Reputation: 558

Running npm audit fix --force ended up upgrading the packages to versions that were not compatible with each other creating this error. Don't blindly run this.

Upvotes: 1

Related Questions