Home > Blockchain >  Nodejs watch mode
Nodejs watch mode

Time:01-17

I want to use watch mode for node js when I type : node --watch index.js I receive : bad option: --watch is there any solution to that ? PS : I'm using node.js version : 16.14.2

CodePudding user response:

You need to update to at least version 18 - https://nodejs.org/en/blog/release/v18.11.0/

CodePudding user response:

This feature was only introduced on v18.11 and it's still experimental:


 nvm use v18.11.0   

 node --watch main.js
  (node:36224) ExperimentalWarning: Watch mode is an experimental feature. 
  This feature could change at any time
  (Use `node --trace-warnings ...` to show where the warning was created) 
 
  hello 1
  hello 2

If you want to use the "watch mode" with Node.js on previous versions, you may want to have a look at:

  • Related