Why it is necessary to determine whether exports.nodeType is empty when making node environment compatibility in the JS library.

Source code information is as follows:

 if (typeof exports != "undefined" && !exports.nodeType) {
if (typeof module != "undefined" && !module.nodeType && module.exports) {
  exports = module.exports = _;
}
exports._ = _;
  } else {
root._ = _;
  }
  

I don"t quite understand why we need to judge whether exports.nodeType and module.nodeType are empty here. The attribute nodeType should be used to determine whether it is a dom element. Can we determine whether the dom element is related to the node environment? Ask the Great God for advice


may be to prevent this situation

<div id="exports"></div>
<div id="module"></div>
Menu