
上QQ阅读APP看书,第一时间看更新
Getting ready
Let's create a new folder called watching-files-and-directories, create a package.json in the folder, and then install the third-party human-time module for nicely formatted time outputs:
$ mkdir watching-files-and-directories
$ cd watching-files-and-directories
$ npm init -y
$ npm install --save human-time
We'll also create a file to watch:
$ echo "some content" > my-file.txt
Finally, we want to create a file called watcher.js (inside the watching-files-and-directories folder) and open it in our favorite editor.