How will you open a file using Node?


Following is the syntax of the method to open a file in asynchronous mode:, flags[, mode], callback)


Here is the description of the parameters used:

  • path - This is string having file name including path.

  • flags - Flag tells the behavior of the file to be opened. All possible values have been mentioned below.

  • mode - This sets the file mode (permission and sticky bits), but only if the file was created. It defaults to 0666, readable and writeable.

  • callback - This is the callback function which gets two arguments (err, fd).


© 2017