Difference Node2-3 & debugging environment ---- module.exports and exports of

exports default setting will give him module.exports as a shortcut, you can add attribute it inside, but we can not modify its point, if modified its ordinary objects and points that it does not have any difference. Because in CommonJS, the external output module is always module.exports and exports if the change point, then it is no longer in force

for example:

10_expos.js

// const = Exports module.exports; 
// ( 
//      function (Exports, the require, Module1, filename __, __ dirname) { 
//          // code 

//      } 
// ); 
// exports.test = 100; 
// below this is OK, that is, ordinary objects 
// Exports = { 
//      a:. 1, 
//      B: 2, 
//      Test: 100 
// } 
module.exports = { 
    a: . 1 , 
    B: 2 , 
    Test: 100 
}

10_main.js

const mod = require('./10_expos')
console.log(mod.test);

 

Guess you like

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