eolas/Programming_Languages/NodeJS/File_system_module.md
2022-04-23 18:30:04 +01:00

757 B

tags
Programming_Languages
backend
node-js
node-modules

File System is an essential built-in module of Node that contains utility methods for working with files and directories.

Every method associated with fs has a blocking and asynchronous implementation. The former obviously blocks the event queue, the latter does not.

The asynchronous methods are useful to have in some contexts but in general and with real-world applications, you should be using the async implementation.

Methods

Read directory

Return a string array of all files in the current directory.


fs.readdir('./', function(err, files) {
	if (err) {
		console.error(err)
	} else {
		console.log(files)	
	}
	
})