Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Ensure that your code adheres to the included `.jshintrc` and `.eslintrc.json` c

*Important:* when fixing a bug, please commit a **failing test** first so that Travis CI (or I can) can show the code failing. Once that commit is in place, then commit the bug fix, so that we can test *before* and *after*.

Remember that you're developing for multiple platforms and versions of node, so if the tests pass on your Mac or Linux or Windows machine, it *may* not pass elsewhere. I personally have Mac and Linux coverage, I need help with Windows tests.
Remember that you're developing for multiple platforms and versions of node, so if the tests pass on your Mac or Linux or Windows machine, they *may* not pass elsewhere. I personally have Mac and Linux coverage, I need help with Windows tests.

## Issues

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You can also install nodemon as a development dependency:
npm install --save-dev nodemon # or using yarn: yarn add nodemon -D
```

With a local installation, nodemon will not be available in your system path or you can't use it directly from the command line. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as `npm start`) or using `npx nodemon`.
With a local installation, nodemon will not be available in your system path, so you can't use it directly from the command line. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as `npm start`) or using `npx nodemon`.

# Usage

Expand All @@ -43,7 +43,7 @@ For CLI options, use the `-h` (or `--help`) argument:
nodemon -h
```

Using nodemon is simple, if my application accepted a host and port as the arguments, I would start it as so:
Using nodemon is simple, if my application accepted a host and port as the arguments, I would start it like so:

```bash
nodemon ./server.js localhost 8080
Expand All @@ -69,7 +69,7 @@ nodemon was originally written to restart hanging processes such as web servers,

## Manual restarting

Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restart nodemon, you can type `rs` with a carriage return, and nodemon will restart your process.
Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restarting nodemon, you can type `rs` with a carriage return, and nodemon will restart your process.

## Config files

Expand All @@ -94,7 +94,7 @@ A config file can take any of the command line arguments as JSON key values, for
}
```

The above `nodemon.json` file might be my global config so that I have support for ruby files and processing files, and I can run `nodemon demo.pde` and nodemon will automatically know how to run the script even though out of the box support for processing scripts.
The above `nodemon.json` file might be my global config so that I have support for ruby files and processing files, and I can run `nodemon demo.pde` and nodemon will automatically know how to run the script even though there is no out-of-the-box support for processing scripts.

A further example of options can be seen in [sample-nodemon.md](https://github.com/remy/nodemon/blob/master/doc/sample-nodemon.md)

Expand Down Expand Up @@ -157,7 +157,7 @@ Now running the following, nodemon will know to use `perl` as the executable:
nodemon script.pl
```

It's generally recommended to use the global `nodemon.json` to add your own `execMap` options. However, if there's a common default that's missing, this can be merged in to the project so that nodemon supports it by default, by changing [default.js](https://github.com/remy/nodemon/blob/master/lib/config/defaults.js) and sending a pull request.
It's generally recommended to use the global `nodemon.json` to add your own `execMap` options. However, if there's a common default that's missing, this can be merged into the project so that nodemon supports it by default, by changing [default.js](https://github.com/remy/nodemon/blob/master/lib/config/defaults.js) and sending a pull request.

## Monitoring multiple directories

Expand All @@ -167,7 +167,7 @@ By default nodemon monitors the current working directory. If you want to take c
nodemon --watch app --watch libs app/server.js
```

Now nodemon will only restart if there are changes in the `./app` or `./libs` directory. By default nodemon will traverse sub-directories, so there's no need in explicitly including sub-directories.
Now nodemon will only restart if there are changes in the `./app` or `./libs` directory. By default nodemon will traverse sub-directories, so there's no need to explicitly include sub-directories.

Nodemon also supports unix globbing, e.g `--watch './lib/*'`. The globbing pattern must be quoted. For advanced globbing, [see `picomatch` documentation](https://github.com/micromatch/picomatch#advanced-globbing), the library that nodemon uses through `chokidar` (which in turn uses it through `anymatch`).

Expand Down Expand Up @@ -253,7 +253,7 @@ nodemon --delay 2.5
}
```

## Gracefully reloading down your script
## Gracefully reloading your script

It is possible to have nodemon send any signal that you specify to your application.

Expand All @@ -272,7 +272,7 @@ process.on("SIGHUP", function () {

Please note that nodemon will send this signal to every process in the process tree.

If you are using `cluster`, then each workers (as well as the master) will receive the signal. If you wish to terminate all workers on receiving a `SIGHUP`, a common pattern is to catch the `SIGHUP` in the master, and forward `SIGTERM` to all workers, while ensuring that all workers ignore `SIGHUP`.
If you are using `cluster`, then each worker (as well as the master) will receive the signal. If you wish to terminate all workers on receiving a `SIGHUP`, a common pattern is to catch the `SIGHUP` in the master, and forward `SIGTERM` to all workers, while ensuring that all workers ignore `SIGHUP`.

```js
if (cluster.isMaster) {
Expand Down Expand Up @@ -356,7 +356,7 @@ The answer is simple, but possibly frustrating. I'm not saying (how I pronounce
- Offer all CLI functionality as an API
- Contributions must have and pass tests

Nodemon is not perfect, and CLI arguments has sprawled beyond where I'm completely happy, but perhaps it can be reduced a little one day.
Nodemon is not perfect, and CLI arguments have sprawled beyond where I'm completely happy, but perhaps they can be reduced a little one day.

## FAQ

Expand Down
4 changes: 2 additions & 2 deletions doc/cli/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Options:

--config file ............ alternate nodemon.json config file to use
-e, --ext ................ extensions to look for, ie. js,pug,hbs.
-x, --exec app ........... execute script with "app", ie. -x "python -v".
-e, --ext ................ extensions to look for, i.e. js,pug,hbs.
-x, --exec app ........... execute script with "app", i.e. -x "python -v".
-w, --watch path ......... watch directory "path" or files. use once for
each directory or file to watch.
-i, --ignore ............. ignore specific files or directories.
Expand Down
4 changes: 2 additions & 2 deletions doc/cli/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Configuration
Execution
-C, --on-change-only ..... execute script on change only, not startup
--cwd <dir> .............. change into <dir> before running the script
-e, --ext ................ extensions to look for, ie. "js,pug,hbs"
-e, --ext ................ extensions to look for, i.e. "js,pug,hbs"
-I, --no-stdin ........... nodemon passes stdin directly to child process
--spawn .................. force nodemon to use spawn (over fork) [node only]
-x, --exec app ........... execute script with "app", ie. -x "python -v"
-x, --exec app ........... execute script with "app", i.e. -x "python -v"
-- <your args> ........... to tell nodemon stop slurping arguments

Watching
Expand Down
4 changes: 2 additions & 2 deletions doc/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nodemon will emit events based on the child process.

- start - child process has started
- crash - child process has crashed (nodemon will not emit exit)
- exit - child process has cleanly exited (ie. no crash)
- exit - child process has cleanly exited (i.e. no crash)
- restart([ array of files triggering the restart ]) - child process has restarted
- config:update - nodemon's config has changed

Expand All @@ -23,7 +23,7 @@ nodemon will emit events based on the child process.
- stderr - the stderr stream from the child process
- readable - stdout and stderr streams are ready ([example](https://github.com/remy/nodemon#pipe-output-to-somewhere-else))

Note that if you want to supress the normal stdout & stderr of the child, in favour
Note that if you want to suppress the normal stdout & stderr of the child, in favour
of processing the stream manually using the stdout/stderr nodemon events, pass
nodemon the option of `stdout: false`.

Expand Down
8 changes: 4 additions & 4 deletions doc/requireable.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Nodemon as a required module

Nodemon (as of 1.0.0) also works as a required module. At present, you can only require nodemon in to your project once (as there are static config variables), but you can re-run with new settings for a different application to monitor.
Nodemon (as of 1.0.0) also works as a required module. At present, you can only require nodemon into your project once (as there are static config variables), but you can re-run with new settings for a different application to monitor.

By requiring nodemon, you can extend it's functionality. Below is a simple example of using nodemon in your project:
By requiring nodemon, you can extend its functionality. Below is a simple example of using nodemon in your project:

```js
var nodemon = require('nodemon');
Expand All @@ -22,7 +22,7 @@ nodemon.on('start', function () {
});
```

Nodemon will emit a number of [events](https://github.com/remy/nodemon/blob/master/doc/events.md) by default, and when in verbose mode will also emit a `log` event (which matches what the nodemon cli tool echos).
Nodemon will emit a number of [events](https://github.com/remy/nodemon/blob/master/doc/events.md) by default, and when in verbose mode will also emit a `log` event (which matches what the nodemon cli tool echoes).

## Arguments

Expand All @@ -40,7 +40,7 @@ The `nodemon` object also has a few methods and properties. Some are exposed to

### Event handling

This is the event emitter bus that exists inside nodemon exposed at the top level module (ie. it's the `events` api):
This is the event emitter bus that exists inside nodemon exposed at the top level module (i.e. it's the `events` api):

- `nodemon.on(event, fn)`
- `nodemon.addListener(event, fn)`
Expand Down
36 changes: 18 additions & 18 deletions faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is a working document, and if it makes sense, I'll take pull requests to he

Rather than being a(nother) feature in nodemon, and as per the [design principles](https://github.com/remy/nodemon#design-principles) you can clear the console using nodemon's existing architecture.

In your `nodemon.json` (or in your `package.json`) you can include the follow event handler to always clear the console when nodemon starts:
In your `nodemon.json` (or in your `package.json`) you can include the following event handler to always clear the console when nodemon starts:

```json
{
Expand All @@ -34,7 +34,7 @@ $ nodemon --watch .env --watch app app/index.js

# nodemon doesn't work with my REPL

Create an nodemon.json file with the setting:
Create a nodemon.json file with the setting:

```js
{
Expand All @@ -60,7 +60,7 @@ nodemon will ignore all script arguments after `--` and pass them to your script

# Error: "process failed, unhandled exit code (2)"

Nodemon will look for exit signals from the child process it runs. When the exit code is `2`, nodemon throws an error. Typically this is because the arguments are bad for the executing program, but it can also be due other reasons.
Nodemon will look for exit signals from the child process it runs. When the exit code is `2`, nodemon throws an error. Typically this is because the arguments are bad for the executing program, but it can also be due to other reasons.

For example, mocha@3.x will exit with `2` on failing tests. To handle the exit code in a way that nodemon can consume, manually exit the process, i.e.:

Expand Down Expand Up @@ -119,19 +119,19 @@ If you see nodemon trying to run two scripts, like:
9 Dec 23:52:58 - [nodemon] starting `node ./app.js fixtures/sigint.js`
```

This is because the main script argument (`fixtures/sigint.js` in this case) wasn't found, and a `package.json`'s main file _was_ found. ie. to solve, double check the path to your script is correct.
This is because the main script argument (`fixtures/sigint.js` in this case) wasn't found, and a `package.json`'s main file _was_ found. i.e. to solve, double check the path to your script is correct.

## What has precedence, ignore or watch?

Everything under the ignore rule has the final word. So if you ignore the `node_modules` directory, but watch `node_modules/*.js`, then all changed files will be ignored, because any changed .js file in the `node_modules` are ignored.
Everything under the ignore rule has the final word. So if you ignore the `node_modules` directory, but watch `node_modules/*.js`, then all changed files will be ignored, because any changed .js files in the `node_modules` are ignored.

However, there are defaults in the ignore rules that your rules will be merged with, and not override. To override the ignore rules see [overriding the underlying default ignore rules](#overriding-the-underlying-default-ignore-rules).

## Overriding the underlying default ignore rules

The way the ignore rules work is that your rules are merged with the `ignoreRoot` rules, which contain `['.git', 'node_modules', ...]`. So if you ignore `public`, the ignore rule results in `['.git', 'node_modules', ..., 'public']`.

Say you did want to watch the `node_modules` directory. You have to override the `ignoreRoot`. If you wanted this on a per project basis, add the config to you local `nodemon.json`. If you want it for all projects, add it to `$HOME/nodemon.json`:
Say you did want to watch the `node_modules` directory. You have to override the `ignoreRoot`. If you wanted this on a per project basis, add the config to your local `nodemon.json`. If you want it for all projects, add it to `$HOME/nodemon.json`:

```json
{
Expand Down Expand Up @@ -159,7 +159,7 @@ Fedora and Ubuntu package node as nodejs, because node.dpkg is
> The node program accepts TCP/IP and packet radio network connections and
> presents users with an interface that allows them to make gateway connections
> to remote hosts using a variety of amateur radio protocols.
> They make the binary is nodejs, rather than node. So long as you're not using that Packet Radio Node Program mentioned above the workaround will work.
They make the binary nodejs, rather than node. So long as you're not using that Packet Radio Node Program mentioned above, the workaround will work.

Thank you [@EvanCarroll](https://github.com/remy/nodemon/issues/68#issuecomment-13672509)

Expand Down Expand Up @@ -188,7 +188,7 @@ forever stop foo

This will stop both nodemon and the node process it was monitoring.

Note that I _would not_ recommend using nodemon in a production environment - but that's because I wouldn't want it restart without my explicit instruction.
Note that I _would not_ recommend using nodemon in a production environment - but that's because I wouldn't want it to restart without my explicit instruction.

## What does "verbose" give me?

Expand All @@ -198,7 +198,7 @@ Additional restart information:

* Which nodemon configs are loaded (local and global if found)
* Which ignore rules are being applied
* Which file extensions are being watch
* Which file extensions are being watched
* The process ID of your application (the `child pid`)
* The process ID of nodemon to manually trigger restarts via kill signals

Expand All @@ -216,7 +216,7 @@ For example:
14 Apr 15:24:58 - [nodemon] child pid: 9292
```

When nodemon detects a change, the following addition information is shown:
When nodemon detects a change, the following additional information is shown:

* Which file(s) triggered the check
* Which (if any) rules the file matched to cause a subsequent restart
Expand Down Expand Up @@ -248,7 +248,7 @@ Note that if you have a `nodemon.json` in your `$HOME` path, then this will also

On Ubuntu globally installed node applications have been found to have no output when they're run. This _seems_ to be an issue with node not being correctly installed (possibly linked to the binary having to be called `nodejs`).

The solution (that's worked in the past) is to install [nvm](https://github.com/creationix/nvm) first and using it to install node, _rather_ than using `apt-get` (or similar tools) to install node directly.
The solution (that's worked in the past) is to install [nvm](https://github.com/creationix/nvm) first and use it to install node, _rather_ than using `apt-get` (or similar tools) to install node directly.

## If nodemon is facing the watch errors (Mac & Linux)

Expand All @@ -266,7 +266,7 @@ The workaround is to use [kill-port](https://github.com/tiaanduplessis/kill-port
nodemon --delay 80ms --exec 'kill-port -k 9228/tcp; node --inspect=0.0.0.0:9228 ./app/http.js'
```

[Original suggestion here](https://github.com/remy/nodemon/issues/1050#issuecomment-323680697) and [addition information here](https://github.com/remy/nodemon/issues/1346#issuecomment-401218386).
[Original suggestion here](https://github.com/remy/nodemon/issues/1050#issuecomment-323680697) and [additional information here](https://github.com/remy/nodemon/issues/1346#issuecomment-401218386).

## Windows: nodemon keeps restarting without changes

Expand All @@ -278,7 +278,7 @@ The workaround is to run the following command:
fsutil behavior set disablelastaccess 1
```

[Futher reading thread](https://github.com/remy/nodemon/issues/1354)
[Further reading thread](https://github.com/remy/nodemon/issues/1354)

## Error: Cannot find module 'internal/util/types'

Expand Down Expand Up @@ -338,17 +338,17 @@ nodemon --ext '*' --watch public --exec 'python -m SimpleHTTPServer'

Based on [this issue](https://github.com/remy/nodemon/issues/2056).

Sometimes when using the `--inspect` flag, nodemon will try to start the a process before the old process is finished.
Sometimes when using the `--inspect` flag, nodemon will try to start a new process before the old process is finished.

This will cause an error trying to up the new process because of the debugger service:
This will cause an error trying to start up the new process because of the debugger service:

```
[0] [nodemon] restarting due to changes...
[0] [nodemon] starting `node --inspect ./main/index.js`
[0] Starting inspector on 127.0.0.1:9229 failed: address already in use
```

Your application will likely be running the old version code if you see that message, and you will need to stop the app and manually start it again to run the app with the newer code version.
Your application will likely be running the old version of the code if you see that message, and you will need to stop the app and manually start it again to run the app with the newer code version.

A common cause for this is when graceful shutdowns are doing async tasks, i.e:

Expand All @@ -362,7 +362,7 @@ process.on('SIGUSR2', async () => {

Simply removing the `await` keyword would likely fix the issue.

If even after that you still running into that problem, there's a workaround to force kill the debugger whenever nodemon triggers a restart.
If even after that you are still running into that problem, there's a workaround to force kill the debugger whenever nodemon triggers a restart.

You can create a `nodemon.json` file at the project root and add the following config:

Expand All @@ -376,4 +376,4 @@ You can create a `nodemon.json` file at the project root and add the following c

This will run a shell command to kill the process running on the PORT 9229 (default node debug port) whenever nodemon triggers a restart.

It may fail sometimes, but it makes the hot reload works partially.
It may fail sometimes, but it makes the hot reload work partially.
Loading