H
H
homm2011-02-15 16:11:27
Node.js
homm, 2011-02-15 16:11:27

How do you restart your local node.js server when developing?

When writing javascript for the browser, you can save the file at any time, switch to the browser and press f5. The new code will be uploaded and can be tested.
When writing in node.js, the code update chain is longer: first you need to switch to the console, stop the server, start the server, go to the browser, press f5.
After the 50th time in a day, it gets very annoying. So I'm wondering how do those who have some development experience with node.js deal with this problem? Are you setting the IDE to restart the server on the build command?
For example, in Django there is no such problem at all, where the development server monitors changes in the source code and automatically restarts itself. And the same php is broadcast on every request.

Answer the question

In order to leave comments, you need to log in

10 answer(s)
A
Alexander Lozovyuk, 2011-02-16
@homm

there are many node restarters, for example, when changing the project code. but usually it is inconvenient

P
Pavlo Ponomarenko, 2011-02-16
@TheShock

Well, personally, I use the following key combination in the console:

ctrl+c
arrowUp
enter

I'm sure you can make it much more convenient, incl. as suggested by VBart

V
VBart, 2011-02-15
@VBart

In KDE, it can be easily hung up on a hotkey or a mouse gesture.

T
Tagire, 2011-02-16
@Tagire

You can write a simple daemon that checks the files in the directory, and if something changes, it restarts the server.

E
eudj1n, 2011-02-17
@eudj1n

I wrote a simple starter.js that hangs in the console (it also respawns the process of the application itself in case of an error).
I kill ctrl + c, allowUp, enter - as TheShock wrote above.
In the case when I write and debug a single script, I use the cloud9 IDE and run the script through the IDE itself (there is both launch and console output).

K
kmike, 2011-02-17
@kmike

Of the restarters (of which there are really a lot), this one was the most convenient for me to use: github.com/lrbabe/node-DJs , because it looks not just for files in some folder, but for changes in the source code.

S
SwampRunner, 2011-02-15
@SwampRunner

It's like debugging nginx, sorry ))

T
Timur Shemsedinov, 2013-11-19
@MarcusAurelius

The Impress application server implements tracking of files that are loaded into via require. When they change, without reloading the project, the old one is removed from memory and a new one is loaded.

M
mrrigin, 2020-03-27
@mrrigin

I am using nodemon.
nodemon app.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question