Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kriasoft/restart
Restart Node.js app in development mode
https://github.com/kriasoft/restart
dev-tool dev-tools development node node-js nodejs nodemon npm npm-scripts script tools watch yarn
Last synced: 29 days ago
JSON representation
Restart Node.js app in development mode
- Host: GitHub
- URL: https://github.com/kriasoft/restart
- Owner: kriasoft
- License: mit
- Created: 2018-04-16T11:23:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-31T18:51:20.000Z (about 6 years ago)
- Last Synced: 2024-04-14T13:08:36.914Z (7 months ago)
- Topics: dev-tool, dev-tools, development, node, node-js, nodejs, nodemon, npm, npm-scripts, script, tools, watch, yarn
- Language: JavaScript
- Size: 20.5 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node.js Restart
[![NPM version](https://img.shields.io/npm/v/restart.svg)](https://www.npmjs.com/package/restart)
[![NPM downloads](https://img.shields.io/npm/dw/restart.svg)](https://www.npmjs.com/package/restart)
[![Build Status](https://img.shields.io/travis/kriasoft/restart.svg)](https://travis-ci.org/kriasoft/restart)This module is designed to restart Node.js app in development mode, e.g. after compilation with
Babel/TypeScript is complete.## How to Install
```bash
$ npm install restart --save-dev
```## How to Use
#### `build/app.js`
```js
const express = require('express');
const app = express();let count = 0;
app.get('/', (req, res) => {
res.send(`count: ${++count}`);
});module.exports = app.listen(8080);
```#### `server.js`
```js
if (process.env.NODE_ENV === 'production') {
// In a production environment launch the Node.js app directly.
require('./build/app');
} else {
// Otherwise, start building the app from source and
// restart it upon new changes in the /build folder.
const restart = require('restart');
const build = require('./scripts/build');
build({
watch: true,
onComplete: () => {
restart({ entry: './build/app' });
},
});
}
``````bash
$ node ./server
```## License
Copyright (c) 2018-present Kriasoft | MIT License