// Jerry 2017-12-9 11:39AM we can currently treat module as a keyword in nodejs environment
var config = require(’./config’);
/*
console.log('module.id: ', module.id);
console.log('module.exports: ', module.exports);
console.log('module.parent: ', module.parent);
console.log('module.filename: ', module.filename);
console.log('module.loaded: ', module.loaded);
console.log('module.children: ', module.children);
console.log('module.paths: ', module.paths);*/

console.log(config.debug);

/*
require 并不是全局性命令,而是每个模块提供的一个内部方法,也就是说,
只有在模块内部才能使用 require 命令(唯一的例外是 REPL 环境)。
另外,require 其实内部调用 Module._load 方法。

模块的加载实质上就是,注入exports、require、module三个全局变量,
然后执行模块的源码,然后将模块的 exports 变量的值输出。

output:
module.id: .
module.exports: {}
module.parent: null
module.filename: C:\Code\git\wechat\app\a.js
module.loaded: false
module.children: []
module.paths: [ ‘C:\Code\git\wechat\app\node_modules’,
‘C:\Code\git\wechat\node_modules’,
‘C:\Code\git\node_modules’,
‘C:\Code\node_modules’,
‘C:\node_modules’ ]

*/

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

关于module require的学习相关推荐

  1. python中module用法_Python学习之module用法

    Python学习之module用法 Python学习之module用法 为什么80%的码农都做不了架构师?>>> Python has a way to put definition ...

  2. require.js学习记录

    1.简介 官方对requirejs的描述: RequireJS is a JavaScript file and module loader. It is optimized for in-brows ...

  3. [Node.js] Module.Require机制研究

    最近开始用Node.js写Server端的脚本,由于原来一直在做的.Net中开发理念的影响,在设计上和代码实现上尽可能地进行封装. Node.js中跟.Net中对象最相近的就是Module(模块)了, ...

  4. ES Module 和 CommonJS 学习笔记(二) —— NodeJS 中使用 ESM 和 CJS

    在 NodeJS 中使用 ES6 模块 当前较新版本的 NodeJS 支持 ESM 和 CJS ,但默认使用的是 CJS 规范去解析 JS 代码,直接使用 CJS 是没有任何问题的,而使用 ESM 需 ...

  5. 5月学习总结(Ant-Design,mustache,require.js,grunt)

    一.Ant-Design学习 因为Ant-Design是基于React实现的,之前自己也学过一段时间的React,对React还是相对比较熟悉的,在学习Ant-Design也还不算吃力. 最开始是从源 ...

  6. require('module') 是什么?

    在很多框架中经常会看到导入 module 模块来使用,那么导入的 module 模块和文件中的 module 变量到底又有什么区别呢? const Module = require('module') ...

  7. ES Module 和 Commonjs | require和import的区别

    1. 语法1.1 ES Module导出:export / export default 导入: import * from 'module'1.2 Commonjs导出:module.exports ...

  8. 解决Module build failed: Error: Cannot find module ‘node-sass‘Require stack

    in ./src/components/main/mainFirm.vueModule build failed: Error: Cannot find module 'node-sass' Requ ...

  9. Node.js学习6~nodejs报Error: Cannot find module ‘express‘

    [现象] D:\work\nodejs\1helloword>node helloword3.js node:internal/modules/cjs/loader:936 throw err; ...

最新文章

  1. 70佳精美的PSD素材免费下载(上篇)
  2. 《城市大脑全球标准研究报告》发布会将于12月23号在北京举办
  3. redis之intset
  4. 加载spring上下文的多种方式总结
  5. 【IT资讯】继哈工大Matlab软件被美禁用后,华为、360再遭Docker软件禁令
  6. 我的世界服务器无限装备指令2020,我的世界区域保护指令_我的世界区域保护指令除了自己手机版刷屏2020_攻略...
  7. Exchange Server 2003 部署手册
  8. 服务器搭建2 VSFTP搭建FTP服务器
  9. 挪车让路,没有留下电话怎么办?
  10. java爬虫新闻网站_java爬虫 之 搜狐新闻爬虫(一)
  11. 企业信息化建设的重要意义及注重方向
  12. Nike Zoom KD 5 “OKC / Away” colorway
  13. bitset优化传递闭包
  14. WPA2/WPA3混合与WPA3的hostapd配置区别
  15. Loadrunner11在Win10上使用踩过的坑
  16. macbook上好用的解压软件_Mac压缩与解压缩软件哪款好用?
  17. 2012年10月2日
  18. 如何将阿拉伯数字转换成RMB大写格式
  19. 全连接神经网络详解(Full Connect Neural Network)
  20. CTeX下的WinEdt和GSview相关的破解和自动补足

热门文章

  1. 02_Jquery_02_元素选择器
  2. 每天学点java_反射作用
  3. Slony-I双机备份
  4. node-mysql中的连接池代码学习
  5. sql server 2005日志文件过大问题解决后分析--针对发布订阅产生的日志问题
  6. [ZT]介绍 10 款非主流的 Web 浏览器
  7. c# winform 应用编程代码总结 5
  8. JVM调优总结(六)-分代垃圾回收详述2
  9. 文献记录(part42)--An end-to-end framework for unconstrained monocular 3D hand pose estimation
  10. sklearn自学指南(part7)--使用手册的目录