DEV Community

Cover image for Day 11 – Creating and Deleting Folders - Learning Node JS In 30 Days [Mini series]
Muhammad Ali (Nerdjfpb)
Muhammad Ali (Nerdjfpb)

Posted on • Originally published at blog.nerdjfpb.com

Day 11 – Creating and Deleting Folders - Learning Node JS In 30 Days [Mini series]

We are on the same fs module for the creating and deleting folders

Alt Text

We are going to use fs.mkdirSync to make new folder

Alt Text

I'm creating a new folder called song by writing fs.mkdirSync('song')

Alt Text

Run it using node app.js
It created a new song folder on the dir

Alt Text

Now we are going to use fs.rmdirSync to delete the folder

Alt Text

We can delete dir by fs.rmdirSync(path) so we'll try it

Alt Text

Run it using node app.js

Alt Text

So we created and deleted folder easily using fs.mkdirSync and fs.rmdirSync

Do you have any questions ?

You can see the graphical version here

Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !

You can read the old posts from here --

Top comments (0)