Search code examples
regexnode.jsnodemon

Nodemon ignore folder using regex expressions


In Nodemon ignore file I want to selectively ignore the folders from my main folder.

My folder structure is :

-modules
  -accounts
 -client
     -angularfiles
        -accounts.js
 -repository
      -accountrepository.js    
-bankbranch
 -client
     -angularfiles
         -bankbranch.js
 -repository
      -bankbranchrepository.js    

In this hierarchy I want to ignore file paths "modules/accounts/client/angularfiles/" & "modules/bankbranch/client/angularfiles/"

I have many more such modules. In this case I tried writing this regex to ignore based on the expression like so :

/modules\\\w*\\client\\angularfiles\\*/

Using the online regex matcher it matches this path :

\AngularJSApp\modules\accounts\client\angularfiles\bankbranch.js 

but nodemon restarts when the file in client\angularfiles is changed.


Solution

  • Nodemon relies on file patterns rather than regular expressions for ignoring some files.

    Try this instead:

    nodemon --ignore 'modules/**/client/angularfiles/*'