Node.js fs.fsync() Method Last Updated : 21 Aug, 2020 Comments Improve Suggest changes Like Article Like Report In Node, the 'fs' module provides an API for interacting with the file system in a manner closely modeled around standard Portable Operating System Interface (POSIX) functions. It has both synchronous and asynchronous forms. The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined. The fs.fsync() method is a kind of asynchronous form. Synchronizes a file with the one stored on the computer. Syntax: fs.fsync(fd, callback); Parameters: This method accepts two parameters as mentioned above and described below: fd: It is a file descriptor (integer) to get in a synchronous way. callback: It is a callback function to check whether any error has occurred. Return Value: This function does not return any value. Example 1: Filename: index.js javascript // Requiring module const fs = require('fs'); // Opening a file const fd = fs.openSync('example.txt', 'r+'); // Function call fs.fsync(fd, (err) => { if(err) { console.log(err); } else { console.log("FD:",fd); } }) Output: FD: 3 Example 2: Filename: index.js javascript // Requiring modules const fs = require('fs'); const express = require('express'); const app = express(); const fd = fs.openSync('example.txt', 'r+'); app.get('/', (req, res) =>{ }); // Function call fs.fsync(fd, (err) => { if(err) { console.log(err) } else { console.log("FD:",fd) } }); // Server setup app.listen(3000, function(error){ if (error) console.log("Error") console.log("Server listening to port 3000") }) Run index.js file using the following command: node index.js Output: Server listening to port 3000 FD: 3 Reference: https://nodejs.org/api/fs.html#fs_fs_fsync_fd_callback Create Quiz Comment B bunnyram19 Follow 0 Improve B bunnyram19 Follow 0 Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-fs-module Explore Introduction & Installation NodeJS Introduction3 min readNode.js Roadmap: A Complete Guide6 min readHow to Install Node.js on Linux6 min readHow to Install Node.js on Windows5 min readHow to Install NodeJS on MacOS6 min readNode.js vs Browser - Top Differences That Every Developer Should Know6 min readNodeJS REPL (READ, EVAL, PRINT, LOOP)4 min readExplain V8 engine in Node.js7 min readNode.js Web Application Architecture3 min readNodeJS Event Loop5 min readNode.js Modules , Buffer & StreamsNodeJS Modules5 min readWhat are Buffers in Node.js ?4 min readNode.js Streams4 min readNode.js Asynchronous ProgrammingAsync Await in Node.js3 min readPromises in NodeJS7 min readHow to Handle Errors in Node.js ?4 min readException Handling in Node.js3 min readNode.js NPMNodeJS NPM6 min readSteps to Create and Publish NPM packages7 min readIntroduction to NPM scripts2 min readNode.js package.json4 min readWhat is package-lock.json ?3 min readNode.js Deployments & CommunicationNode Debugging2 min readHow to Perform Testing in Node.js ?2 min readUnit Testing of Node.js Application5 min readNODE_ENV Variables and How to Use Them ?2 min readDifference Between Development and Production in Node.js3 min readBest Security Practices in Node.js4 min readDeploying Node.js Applications5 min readHow to Build a Microservices Architecture with NodeJS3 min readNode.js with WebAssembly3 min readResources & ToolsNode.js Web Server6 min readNode Exercises, Practice Questions and Solutions4 min readNode.js Projects9 min readNodeJS Interview Questions and Answers15+ min read Like