I tried express-livereload
, but it just reloaded view files.
Should I use another tool, or this one can be configured to watch for my index.js
file which runs the server?
I read that options are the same as node-livereload
, and default for watched files include .js
files.
Any URL you know with a simple configuration?
My main problem is how to setup good development environment for Express.js, and I would like to inspect the variables when I am making a request, is painful to restart each time I make a change in a route.
PS I tried node-inspector
to inspect variables when server handles a request, but it seems node-inspector
is not intended for that, right?
nodemon restarts the server on any changed backend file.
A route method is derived from one of the HTTP methods, and is attached to an instance of the express class. The following code is an example of routes that are defined for the GET and the POST methods to the root of the app. Express supports methods that correspond to all HTTP request methods: get , post , and so on.
If it's just running (not a daemon) then just use Ctrl-C.
It is unmaintained Express has not been updated for years, and its next version has been in alpha for 6 years. People may think it is not updated because the API is stable and does not need change. The reality is: Express does not know how to handle async/await .
I think Nodemon has what you're looking for.
Nodemon is a utility that will monitor for any changes in your source and automatically restart your server. Perfect for development.
Example invocation:
nodemon index.js
I use express.js, normally start server by
npm start
with Nodemon installed, I use
nodemon --exec npm start
Note: nodemon app.js
will NOT work here,
because express.js use start
script
To install nodemon
npm install -g nodemon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With