Node2-2 & debugging environment ---- reference system built-in modules, citing third-party modules

Method reference system built-in module

08_fs.js

// reference system built in modules method 
const the require FS = ( 'FS' ); 
const Result = fs.readFile ( './ 08_fs.js', (ERR, Data) => {
     IF (ERR) { 
        the console.log ( ERR);    
    } the else { 
        the console.log (data.toString ()); 
    } 
}); 
the console.log (Result);

 

 

Referenced third-party modules (chalk)

First installation

Then the folder will be more of a file node_modules

09_chalk.js

Direct write the name, the first step will direct examination node.js was built module, but not built, it will have to check the current path where node_modules, and then not check checks ... step by step through the parent class
const chalk = require('chalk')
console.log(chalk.red('this is red'));

operation result

 

Guess you like

Origin www.cnblogs.com/chorkiu/p/11414121.html