Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodemon - exclusion of files

Tags:

nodemon

People also ask

How do I ignore Nodemon files?

You can use ls 'your exlusions' && nodemon app. js (not cross platform). If you are willing to write code for it, you can listen to nodemon 'start' or 'restart' event and print excluded files by reading nodemon config and expanding glob patterns in "ignore" array.

Does Nodemon ignore Node_modules?

Note that by default, nodemon will ignore the . git and node_modules/**/node_modules directories.

How do I use Nodemon with TypeScript?

When you call nodemon with a TypeScript file (i.e., nodemon index. ts ), nodemon will find the command in the execMap that correlates to . ts files and then run that command, passing the file as the final argument (i.e. ts-node index. ts ).


In order to make NodeMon ignore a bunch of files from monitoring, you can start it as

nodemon --ignore PATTERN [--ignore PATTERN2]

where PATTERN is the name of a specific file, directory, or wildcard pattern. Make sure that if you use a wildcard, it is escaped.

For example

nodemon --ignore 'lib/*.js' --ignore README

Alternatively, if you want to configure that behaviour instead, try creating a nodemon.json file in your current working directory, or your home directory. You can configure ignoring some files by adding something like the following to this config file:

{   
    "ignore": ["lib/*.js", "README"] 
}

Refer the README file at https://github.com/remy/nodemon for more details.


You can add nodemon configuration within package.json file For example:

{
  "name": "nlabel",
  "version": "0.0.1",
   // other regular stuff


  "nodemonConfig": {
    "ignore": ["public/data/*.json", "public/javascripts/*.js"]
  },


  "author": "@sziraqui",
  "license": "GPL-3.0"
}

The key must be "nodemonConfig". Ignore rules can be specified as array of globs or complete filenames

More info: https://github.com/remy/nodemon#packagejson


For me (Mac and nodemon 1.18.3), the only way to ignore entire directories is to run e.g.

nodemon --ignore "**/old/**"

with the double quote and **. The config file won't work.

I have set up an alias like this:

alias nm='nodemon server.js -i "**/old/**" -i "**/img/**"'

Check what files are monitored by running

DEBUG=nodemon:watch nodemon server.js -i "**/old/**" -i "**/img/**"

-i is an alternative to --ignore. Check out the available parameters with nodemon --help