Nodejs Course

To easily work with directories and files on server, use the fs-extra module.
It can be a drop in replacement for "fs" build-in module.
- Before using the "fs-extra" module, you have to install it. To install "fs-extra", run this code in command line interface:
npm install --save fs-extra
Then, you can use the fs-extra module in your Node.js projects, as a drop in replacement for native fs.
const fs = require('fs-extra');

Moving directory

A simple way to move a directory in Node.js it is to use the fs.move(oldPath, newPath, callback) method of the fs-extra module.
- Example: move 'dir_2/' directory from 'test/' to 'dirx/':
const fs = require('fs-extra');

fs.move('./test/dir_2/', './dirx/dir_2/', err => {
  if(err) return console.error(err);
  console.log('success!');
});

Copy directory

To copy a directory in Node.js, you can use the copy() method of the fs-extra module.
Example: Copy the 'dir_2/' directory from 'test/' to 'dirx/':
const fs = require('fs-extra');

fs.copy('./test/dir_2/', './dirx/dir_2/', err =>{
  if(err) return console.error(err);
  console.log('success!');
});

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag is a block element?
<div> <img> <span>
<div>Web Programming and Development</div>
Which CSS code displays the text underlined?
font-style: italic; text-decoration: underline; font-weight: 500;
h2 {
  text-decoration: underline;
}
Click on the JavaScript function that can access other function after a specified time.
insertBefore() setTimeout() querySelector()
function someFunction() { alert("CoursesWeb.net"); }
setTimeout("someFunction()", 2000);
Click on the instruction that returns the number of items of a multidimensional array in PHP.
count($array) count($array, 1) strlen()
$food =["fruits" =>["banana", "apple"), "veggie" =>["collard", "pea"));
$nr_food = count($food, 1);
echo $nr_food;       // 6
Node.js Move and Copy Directory

Last accessed pages

  1. Date and Time in ActionScript 3 (10091)
  2. jQuery parent, children and nth-child() (13873)
  3. RegExp - Regular Expressions in ActionScript (4713)
  4. JavaScript strip_tags and stripslashes (8829)
  5. Complex Shapes with a single DIV and CSS (3711)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (643)
  2. The Mastery of Love (75)
  3. CSS cursor property - Custom Cursors (71)
  4. Read Excel file data in PHP - PhpExcelReader (67)
  5. PHP-MySQL free course, online tutorials PHP MySQL code (48)