Node.js Glob Module Example to Print Names of All Files inside a Directory Using Javascript Full Example For Beginners

 

Welcome folks today in this blog post we will be printing all files names which are present inside the directory in node.js using glob module. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the below library using the npm command as shown below

 

 

npm i glob

 

 

After installing this library make an index.js file and copy paste the following code

 

 

index.js

 

 

var glob = require("glob")

// options is optional
glob("**/*.js", options, function (er, files) {
  // files is an array of filenames.
  // If the `nonull` option is set, and nothing
  // was found, then files is ["**/*.js"]
  // er is an error object or null.
})

Leave a Reply