- Node Cookbook(Third Edition)
- David Mark Clements Matthias Buus Matteo Collina Peter Elger
- 75字
- 2024-10-29 20:27:02
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.