這是nodejs源碼module.js的代碼 https://github.com/nodejs/nod...const NativeModule = require('native_module');const util = require('util');const internalModule = require('internal/module');const vm = require('vm');const assert = require('assert').ok;const fs = require('fs');const internalFS = require('internal/fs');這是require的源碼Module.prototype.require = function(path) {assert(path, 'missing path');assert(typeof path === 'string', 'path must be a string');return Module._load(path, this, / isMain / false);};module.js是實現(xiàn)require函數(shù)的,為什么第一行就調(diào)用了require,require函數(shù)不是還沒實現(xiàn)嗎?沒想明白,感覺有點用結(jié)果去實現(xiàn)結(jié)果的意思,新人求指教。
nodejs模塊源碼require問題
拉風(fēng)的咖菲貓
2018-10-19 13:15:38