So if we had a file, I'm just going to call it test.js, and I do some, let's do a console.log here. To execute this file, all I would have to do is go into a terminal, type in node, and then the path to that file, which is test. I don't have to put test.js, I could just put test and it will execute it. So there it is, the console.log heeeey. It executed it, and then it exited it. Alright, so it's not running continuously. Alright, so anything that I do in here, it'll work.
There we go. - [Attendee] Did you get the question on the, he's seen some people use exports equals module.exports, what does that mean? - Yeah, so that's, that's a really So that's like a way to like safeguard yourself from not doing a module.exports and then doing an exports somewhere else in the file. So by doing exports equals modules.exports, that's like, I'm just going to, you know, keep everything safe. So I'm still only going to be able to export one thing and then I'm guaranteed that sometime in the future, I don't come down here and say exports, You know exports.other equals like a value and then that would never be, that would never get exported, because we had a modules.export.
So it's just a way of, like, keeping yourself safe. You don't have to do it, but there are a lot of patterns as far as exporting. I'll show you some of the other patterns. But that's a pretty standard pattern, you see that a lot. But it's just a way of, like, making sure you don't try to export something later after your module.export, and not have it be able to be required in another file and have some unexpected side-effects.
This course was created by Frontend Masters. It was originally released on 12/30/2015. We're pleased to host this training in our library.
- Executing Node.js
- Using Express
- What is middleware?
- Testing in Node.js
- Using Mongo with Node.js
- Data modeling
- Querying data with Mongoose
- Identifying sensitive routes
- Configuring the deployment
Skill Level Intermediate
Building a Slack Bot with Node.js Microserviceswith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
2. REST APIs
5. Organization and Configuration
7. Data Modeling
10. Securing Routes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.