One of the first things that most developers learn when starting with ExpressJS is using Express Generator to create a basic app structure. After i...
For further actions, you may consider blocking this person and/or reporting abuse
I did the same but its not reloading my files. I am using ejs.
//Newbie
Most probably is because by default
nodemon
watch for.js, .mjs, .coffee, .litcoffee, .json
extensions. Therefore you can send the flag of-e ejs
to the command ofwatch
to make it watch your files :)"From now on, run the server with npm run watch instead of npm start."
Config package.json thus. "dev": "nodemon --ext * ' js,html,ejs,css,scss" app.js"
Great...
@cassiolacerda thanks for the guide! It worked great for me. Is there a way to make livereload run only in my development environment? Right now if I try to deploy to production with liveserver changes in my app.js, it breaks everything.
You need to have a concept of environments. Typically
process.env.NODE_ENV
is used. After you have a environment declared, conditionally set the middleware.Great quote! Even if something only takes a few seconds, automating it can save us hours and hours in the long run. As I've improved as a software developer, the more and more I prioritize these types of things
Hello. Can you help?
Why when I did some changes page on localhost:port/users or any other endpoint nodemon don't reload this page?
Working only on root.
Hello, guy!
Livereload works only with rendered HTML pages. It needs to inject a script tag that points to the server created by Livereload on port 35729 (see in the last section).
The endpoint
/users
encountered in the repo send data to client-side withres.send
method, where data type generated by that isapplication/json
. In home endpoint/
, the application usesres.render
to outputstext/html
data, so it works here, and not in/users
.Thanks.
This works for me although live reload is kinda slow compared to HMR in other build tools.
Worked like a charm for me. Thank you!
This works for me although live reload is kinda slow.
How this can be used with NodeJs using the HTTP module to create the webserver and not EXPRESSJS
good
Thank you very much for that ! I was looking for something like that since few months !
bin file issues that deem this not working for me
Hi. I had a problem with bin and it didn't work like you.
This worked fine. bytearcher.com/articles/refresh-ch...
I wish you wellπ