- Learning Node.js Development
- Andrew Mead
- 175字
- 2021-06-30 18:56:48
Exporting files from note.js to use in app.js
For now though, the focus will be to export something from notes.js which we can use in app.js. Inside notes.js (actually, inside all of our Node files), we have access to a variable called module. I'll use console.log to print module to the screen so that we can explore it over in Terminal, as shown here:
console.log('Starting notes.js');
console.log(module);
Let's rerun the file to explore it. As shown in the following screenshot, we get a pretty big object, that is, different properties related to the notes.js file:

Now, to tell the truth, we'll not be using most of these properties. We have things such as id, exports, parent, and filename. The only one property we'll ever use in this book is exports.
The exports object on the module property and everything on this object gets exported. This object gets set as the const variable, notes. This means that we can set properties on it, they will get set on notes, and we can use them inside app.js.
- 物聯網智慧安監技術
- 走進物聯網
- 網絡互聯技術(實踐篇)
- Socket.IO Real-time Web Application Development
- 計算機網絡與通信(第2版)
- 物聯網之霧:基于霧計算的智能硬件快速反應與安全控制
- 新手易學:新手學淘寶開店
- Getting Started with Memcached
- 從實踐中學習手機抓包與數據分析
- AWS Lambda Quick Start Guide
- 全聯網標識服務
- 物聯網技術與實踐
- Hands-On Cloud:Native Microservices with Jakarta EE
- OpenShift Cookbook
- Citrix XenDesktop 5.6 Cookbook