pirple/The-NodeJS-Master-Class

fs.truncate with a descriptor is deprecated.

Opened this issue · 1 comments

In section three, we create the update functionality and are instructed to use fs.truncate but I received a warning from node:

(node:29626) [DEP0081] DeprecationWarning: Using fs.truncate with a file descriptor is deprecated. Please use fs.ftruncate with a file descriptor instead.

lokyi commented

Looks like you would get this error if you are using node v10 while @pirple-author is targeting Node v8.

Using fs.truncate with a file descriptor will actually call fs.ftruncate, according to the doc

Maybe it is more appropriate to use fs.ftruncate in production, but for demonstration purposes, using truncate is more intuitive?