skip to Main Content

So I’m getting this error every time I run any react native application on my system.
The metro builder crashes almost instantaneously as soon as I start the application.
This happens with expo and react native cli apps both.
While in this screenshot I’m using a monorepo, I have encountered this error in other react native applications too.

screenshot of the error

I have tried opening vscode in admin mode but the error is still there.
Have also tried changing the prefix using the
npm edit config

Would really appreciate some help on this.

2

Answers


  1. Try This :->

    (1) npm cache clean --force
    
    (2) rm -rf node_modules package-lock.json
    
    (3) npm install
    
    (4) npm start
    
    Login or Signup to reply.
  2. TL;DR; Have Metro ignore changes in the respective directory

    1. If it doesn’t exist, create a file named metro.config.js in your project’s root directory.
    2. The file should include the following lines:
    // 'exclusionList' used to be called 'blacklist' before React Native 0.64
    const exclusionList = require('metro-config/src/defaults/exclusionList');
    // ...
    module.exports = {
    // ...
      resolver: {
        blacklistRE: exclusionList([
          new RegExp("^E:/<your_path_name>\/.git\/.*$"),
          // ...
        ]),
        // ...
      }
    }
    

    What’s going on

    To implement hot reloading, Metro is constantly watching for file changes in the project directory. In your case, Metro tried to read the information on a file without having the necessary permissions. .git/fsmonitor--deamon ironically watches for file changes, too, and creates cookie files in the process. These cookies are only for use by git itself, therefore the restrictive access policy.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search