From the course: Node.js Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Creating directories - Node.js Tutorial
From the course: Node.js Essential Training
Creating directories
- [Eve] We can also create directories with the file system module's mkdir function. So let's create a new file and create some directories. I've created this new file here called directory.js, which is going to start with our require statement. And then we're going to use the asynchronous mkdir method and make a directory called your-files-here. So if we wanted to do this synchronously, of course we would use mkdirSync, but we want to use mkdir. The first argument we'll send here is your-files-here. Then we'll add this function with an error, and we'll say if the error occurs, then we want to console.log an error in a little template string here. Otherwise, we will message our user to let 'em know that the directory was created. So here we'll say directory created. Now we want to run this with node directory, and it looks like, if I type ls, we've created a directory called your-files-here. And if I type open. or…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Listing directory files2m 25s
-
(Locked)
Reading files2m 19s
-
(Locked)
Writing and appending files3m 22s
-
(Locked)
Creating directories2m 26s
-
(Locked)
Renaming and removing files3m 29s
-
(Locked)
Renaming and removing directories3m 57s
-
(Locked)
Readable file streams5m 47s
-
(Locked)
Writable file streams4m 47s
-
(Locked)
-