{"id":13447501,"url":"https://github.com/fgnass/node-dev","last_synced_at":"2025-05-13T21:04:30.298Z","repository":{"id":1116258,"uuid":"986572","full_name":"fgnass/node-dev","owner":"fgnass","description":"Zero-conf Node.js reloading","archived":false,"fork":false,"pushed_at":"2023-09-19T02:50:59.000Z","size":764,"stargazers_count":2252,"open_issues_count":34,"forks_count":112,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-05-11T16:01:57.202Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fgnass.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2010-10-14T10:11:49.000Z","updated_at":"2025-05-02T05:51:30.000Z","dependencies_parsed_at":"2024-01-08T08:04:35.479Z","dependency_job_id":null,"html_url":"https://github.com/fgnass/node-dev","commit_stats":{"total_commits":361,"total_committers":37,"mean_commits":9.756756756756756,"dds":0.4404432132963989,"last_synced_commit":"9ab4eb61a6cc67e6bcfe9de65770e6e345179636"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgnass%2Fnode-dev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgnass%2Fnode-dev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgnass%2Fnode-dev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgnass%2Fnode-dev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fgnass","download_url":"https://codeload.github.com/fgnass/node-dev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254028420,"owners_count":22002250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:19.466Z","updated_at":"2025-05-13T21:04:30.249Z","avatar_url":"https://github.com/fgnass.png","language":"JavaScript","readme":"[![Build Status](https://secure.travis-ci.org/fgnass/node-dev.png)](http://travis-ci.org/fgnass/node-dev)\n\n### node-dev (1)\n\nNode-dev is a development tool for [Node.js](http://nodejs.org) that\nautomatically restarts the node process when a file is modified.\n\nIn contrast to tools like [supervisor](https://github.com/isaacs/node-supervisor) or [nodemon](https://github.com/remy/nodemon) it doesn't scan the filesystem for files to be watched. Instead it hooks into Node's `require()` function to watch only the files that have been _actually required_.\n\nThis means that you don't have to configure any include- or exclude rules. If you modify a JS file that is solely used on the client-side but never run on the server, **node-dev will know** this and won't restart the process.\n\nThis also means that you **don't have to** configure any file extensions. Just require a `.json` file or a `.ts` script for example and it will be watched. Automatically.\n\n# Usage\n\nJust run `node-dev` as you would normally run `node`:\n\n```\nnode-dev server.js\n```\n\n## TypeScript support\n\nYou can use node-dev to watch and restart TypeScript projects. Install [ts-node](https://www.npmjs.com/package/ts-node) as dev-dependency, then use node-dev to run your script:\n\n```\nnode-dev src/server.ts\n```\n\n## Command-line options\n\nThere are a couple of command-line options that can be used to control which files are watched and what happens when they change:\n\n- `--clear` - Clear the screen on restart\n- `--debounce` - Debounce change events by time in milliseconds (non-polling mode, default: 10)\n- `--dedupe` - [Dedupe dynamically](https://www.npmjs.org/package/dynamic-dedupe)\n- `--deps`:\n  - `-1` - Watch the whole dependency tree\n  - `0` - Watch only the project's own files and linked modules (via `npm link`)\n  - `1` (_Default_) - Watch all first level dependencies\n  - `\u003cnumber\u003e ` - Number of levels to watch\n- `--fork` - Hook into child_process.fork\n- `--graceful_ipc \u003cmsg\u003e` - Send 'msg' as an IPC message instead of SIGTERM for restart/shutdown\n- `--ignore` - A file whose changes should not cause a restart\n- `--interval` - Polling interval in milliseconds (default: 1000)\n- `--notify=false` - Disable desktop notifications\n- `--poll` - Force polling for file changes (Caution! CPU-heavy!)\n- `--respawn` - Keep watching for changes after the script has exited\n- `--timestamp` - The timestamp format to use for logging restarts\n- `--vm` - Load files using Node's VM\n\n## Passing arguments to node\n\nAll command-line arguments that are not `node-dev` options are passed on to the `node` process.\n\nPlease note: you may need to separate your script from other command line options with `--`, for example:\n\n`node-dev --some-node-args -- my-script.js`\n\n# Installation\n\n`node-dev` can be installed via `npm`. Installing it with the `-g` option will allow you to use it anywhere you would use `node`.\n\n```\nnpm install -g node-dev\n```\n\n### Desktop Notifications\n\nStatus and error messages can be displayed as desktop notification using\n[node-notifier](https://www.npmjs.org/package/node-notifier):\n\n![Screenshot](./images/node-dev.png)\n\n![Screenshot](./images/node-dev-linux.png)\n\n**Requirements:**\n\n- Mac OS X: \u003e= 10.8\n- Linux: `notify-osd` or `libnotify-bin` installed (Ubuntu should have this by default)\n- Windows: \u003e= 8, or task bar balloons for Windows \u003c 8\n\n# Config file\n\nUpon startup node-dev looks for a `.node-dev.json` file in the following directories:\n\n- the user's home directory\n- the current working directory\n- the same directory as the script to run\n\nSettings found later in the list will overwrite previous options.\n\n## Configuration options\n\nUsually node-dev doesn't require any configuration at all, but there are some options you can set to tweak its behaviour:\n\n- `clear` – Whether to clear the screen upon restarts. _Default:_ `false`\n- `dedupe` – Whether modules should by [dynamically deduped](https://www.npmjs.org/package/dynamic-dedupe). _Default:_ `false`\n- `deps` – How many levels of dependencies should be watched. _Default:_ `1`\n- `fork` – Whether to hook into [child_process.fork](http://nodejs.org/docs/latest/api/child_process.html#child_process_child_process_fork_modulepath_args_options) (required for [clustered](http://nodejs.org/docs/latest/api/cluster.html) programs). _Default:_ `true`\n- `graceful_ipc` - Send the argument provided as an IPC message instead of SIGTERM during restart events. _Default:_ `\"\"` (off)\n- `ignore` - A single file or an array of files to ignore. _Default:_ `[]`\n- `notify` – Whether to display desktop notifications. _Default:_ `true`\n- `poll` - Force polling for file changes, this can be CPU-heavy. _Default:_ `false`\n- `respawn` - Keep watching for changes after the script has exited. _Default:_ `false`\n- `timestamp` – The timestamp format to use for logging restarts. _Default:_ `\"HH:MM:ss\"`\n- `vm` – Whether to watch files loaded via Node's [VM](http://nodejs.org/docs/latest/api/vm.html) module. _Default:_ `true`\n\n### ESModules\n\nWhen using ESModule syntax and `.mjs` files, `node-dev` will automatically use a loader to know which files to watch.\n\n### Dedupe linked modules\n\nSometimes you need to make sure that multiple modules get _exactly the same instance_ of a common (peer-) dependency. This can usually be achieved by running `npm dedupe` – however this doesn't work when you try to `npm link` a dependency (which is quite common during development). Therefore `node-dev` provides a `--dedupe` switch that will inject the [dynamic-dedupe](https://www.npmjs.org/package/dynamic-dedupe) module into your app.\n\n### Transpilers\n\nYou can use `node-dev` to run transpiled languages like TypeScript. You can either use a `.js` file as entry point to your application that registers your transpiler as a require-extension manually, for example by calling `CoffeeScript.register()` or you can let node-dev do this for you.\n\nThere is a config option called `extensions` which maps file extensions to compiler module names. By default the map looks like this:\n\n```json\n{\n  \"coffee\": \"coffee-script/register\",\n  \"ls\": \"LiveScript\",\n  \"ts\": \"ts-node/register\"\n}\n```\n\nThis means that if you run `node-dev server.ts` node-dev will do a\n`require(\"ts-node/register\")` before running your script. You need\nto have `ts-node` installed as a dependency of your package.\n\nOptions can be passed to a transpiler by providing an object containing `name` and `options` attributes:\n\n```json\n{\n  \"js\": {\n    \"name\": \"babel-core/register\",\n    \"options\": {\n      \"only\": [\"lib/**\", \"node_modules/es2015-only-module/**\"]\n    }\n  }\n}\n```\n\n### Graceful restarts\n\nNode-dev sends a `SIGTERM` signal to the child-process if a restart is required. If your app is not listening for these signals `process.exit(0)` will be called immediately. If a listener is registered, node-dev assumes that your app will exit on its own once it is ready.\n\nWindows does not handle POSIX signals, as such signals such as `SIGTERM` cause the process manager to unconditionally terminate the application with no chance of cleanup. In this case, the option `graceful_ipc` may be used. If this option is defined, the argument provided to the option will be sent as an IPC message via `child.send(\"\u003cgraceful_ipc argument\u003e\")`. The child process can listen and\nhandle this event with:\n\n```javascript\nprocess.on('message', function (msg) {\n  if (msg === '\u003cgraceful_ipc argument\u003e') {\n    // Gracefully shut down here\n    doGracefulShutdown();\n  }\n});\n```\n\n### Ignore paths\n\nIf you’d like to ignore certain paths or files from triggering a restart, list them in the `.node-dev.json` configuration under `\"ignore\"` like this:\n\n```json\n{\n  \"ignore\": [\"client/scripts\", \"shared/module.js\"]\n}\n```\n\nThis can be useful when you are running an isomorphic web app that shares modules between the server and the client.\n\n## License\n\nMIT\n","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgnass%2Fnode-dev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgnass%2Fnode-dev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgnass%2Fnode-dev/lists"}