2

I'm doing small programming challenges locally.

In one tab I draft a solution, let's call it challenge.js and in another tab I run the command node challenge.js whenever I make a change.

Is there a way for node to compile automatically whenever a change has been made to challenge.js?

timothyylim
  • 1,399
  • 2
  • 14
  • 32

3 Answers3

9

The first comment answered the question.

I installed nodemon:

$ npm install nodemon -g
$ nodemon app.js

and it works perfectly.

timothyylim
  • 1,399
  • 2
  • 14
  • 32
0

This is for development environment? If yes, you can use a build tool like webpack, gulp, etc.

Webpack provides a tool webpack-dev-server, that recompile your bundle at every change.

I hope to have helped.

0

Use nodemon. https://www.npmjs.com/package/nodemon I work in server development and it refershes the server every time I save a file. If its a case you want something live to restart every time it crashes or if theres any change use pm2 https://www.npmjs.com/package/pm2

Dennington-bear
  • 1,732
  • 4
  • 18
  • 44