To use the utimesSync()
function from the fs-extra
package in Node.js, first install the package via npm by running:
index.tsx21 chars2 lines
Then, you can import the package and use the utimesSync()
method as follows:
index.tsx231 chars11 lines
The utimesSync()
method takes in three arguments: the path to the file, the new access time (set to now
in the example above), and the new modified time (also set to now
). This function sets the file's timestamps to the provided values.
Note: this function can only change the timestamp of a file, not create one. If the specified file does not exist it will throw a ENOENT
error.
gistlibby LogSnag