Node.js How Modules Works & NPM #02

CoderOne · Beginner ·🛠️ AI Tools & Apps ·8y ago
Full Tutorial: http://go.ipenywis.com/ipenydac9 --- Official Links---- Official Website: http://ipenywis.com Official Facebook: http://go.ipenywis.com/ipeny4907 Official Twitter: http://go.ipenywis.com/islem9a03 Official GitHub Repo: http://go.ipenywis.com/ipeny5c0e ---Support US--- By Becoming a Patreon: http://go.ipenywis.com/ipeny5024

What You'll Learn

This video tutorial covers Node.js modules and NPM, demonstrating how to import and export modules, install packages, and manage dependencies using tools like Node.js, NPM, and Express.

Full Transcript

helping guys are all doing welcome to the second episode on the node.js series of explaining ideas and the modules so in this actually tutorial we're going to explain the modules and why you need to use them in your application and why actually they have a very very important thing to use and what is actually an MDM so NPM is the node package or node Nordia Smulders package manager so it's like a package managers that allow you to find packages and install them the eruption into your nodejs application or repository so here if we go to them MPN j is calm you can find packages easily you can call them packages or modules packages for bigger more scalable things and modules for a smaller one but there's a much everything so you can find packages for example is the request package in here or the request model what's actually allow you to do is a simplified HTTP request so you can just send request from your application into an HTTP server out there and get responses very easily so to wrapper and do the HTTP api it may gonna make your life easier and for send HTTP requests and receiving responses in here and a lot of other things you can use right out of a box in here so let me just briefly explain how modules work and how you can use them on your like application in here i have made that genius file in here and i want to create another file in here to represent how things actually work so let me just I don't know modules or my mods for example like my modules in here that you shouldn't call this something English so let me just put that in the main directory so in here I'm gonna create another file I don't know let's call this utils cough genius so like let's say this has the needed functions or the chills functions that I don't get any use on my application so Justice Bureau functions so actually how are those words you cannot use require the require function will require method so when you put the name of module no T is gonna go and find that into the file system then I'm gonna grab everything into that file and just gonna put this into your under your memory or your RAM and whenever you just need to call a function or something you're just gonna go to the round and grab the function and let you execute that right out the box in very very easy and simplified way so this how actually the require if you have been here in the parts if you don't so require just used to import modules even what is that heart and start from the npm so as i've said all you do is declare power point if so let's say me for example so this time anywhere else that's another one let's select declare a function gets full name and this function is gonna return my knee so how can I access that name from from another like from the main genius um how can I require this how can I make this file a modular and it can require to the major gears so you can use this function get for me and get get over it so all you do is use the exports keyword from the node a specific thing so from like every model no Jason objects how you do that you export things so exports don't say and you put the name so let's say get full name and it's gonna equals this function and whenever we're gonna call or require this into the main top J as we can it uses right out of the box so this like you very really simple I'm simplifying thing I don't know let me just use this so we can acquire that require my shirts under the current directory I'm gonna put you tails in here and I'm gonna require so let's use Hills so whenever we want to call this function so what we do is just go there down here let me just console.log my name and for example we put my name and put utils don't get for me as I've said this will return the full name that is stored in the only other fun you can also use ESX imports for some of you say like why not use the ESX exponent for keywords rather than using that this is like more efficient thing and more noj's compatible thing so just use it for node.js module something like this now if you execute that and we puts like node meas this should friends my name is it something you associate as I've said and as you can see actually here and we don't have a name here defined so to find end of the utils but we're requiring it then we get the full name so whenever you want to export something to use it on another file or another module or something like that use the export keyword and get for me then assign the the name you wanna off your function or your class or your variable then assign it to to the the variable or the body you want to export over here and it's gonna just work absolutely fine in here everything is very simple finally as I've said also another thing you can use variable that we have been talking about so just put down and we can just examine how things like works in here so all we do is just let me use the require function and let's say we are going to require the utils again so utils and let me just put this like in the current directory and the well so to actually show what the require returns in here so what does that require think is going to return in here just gonna return an object so if you execute that we get an object and it only has to get full name function and that function so since we are exporting that so requires gonna go ahead a look utyos' and find any export function or into the exports objects and data signage or returning him in that particular object that's why we're getting the get form name and the type of that is a function so this all what require does on specific modules if you have been using node.js for now so require we're just gonna go ahead require and use the export functions in here and I'm gonna give you that specific things so you can use that export function to export anything any type of data from one module to another or you can use the test in your application in years I've said it's very very efficient and really easy to use also the other thing if your might be wondering how you can install modules stuff already be defined so the modules from only NPM and you can also just go ahead and search for them let's say Express and Express it out the the framework that will allow you to create service back-end service using javascript in ojs and actually this like a very very popular thing and it's very really use of non-being so you can just all you do is npm install then put the module name so let's say the request since it's just minimalistic and the other one we're gonna explain is just the save and the save damn what are the differences between those so the save flag is just gonna save it as and made your dependency which means when you finish with the application so you want to keep for you two to your services it's a web application so you want to deploy it from your local development environments into your distributed or cloud d-block development server or development environment so you wanna order your production server option so you wanted to point from a local machine and do the other one all you do is just deploy the I'll take all the files it's not just gonna work like this because we are saving in here when we puts we're gonna save two different things two different type of dependency is gonna save the dependencies normally been disease and the dev dependencies and the dev dependencies are all available in your local machine so whenever you deploy it is not going to be available to the production server but for we just use the safe bag without the - death this cannot be available or gonna be deployed into the actual service show things like the request thing so in it must be deployed so let's say for example you are going to use webpack it's just gonna be involved for developing because this is gonna compile files on your machine and that's it so it's not gonna be using the production server Express just gonna be use it only or you're just gonna use on the production server just use the same or Celsius request so the same flag NPM install request and now just aren't gonna just do the request and start looking for our package and then installing it and you're gonna find like a boulder and you're just gonna appear miss acumen here it's called node modules which going to hold everything as I've said node modules in here all the modules are needed also the modules I like the double order from all the repositories with your machine works where like a cup of repositories or milk for depositories so we gotta find all the modules in here from the cache and actually everything's gonna be settled up in here also the standard model that's only the one you download the standard one like the file systems how we enter the file system that will allow you to interact this finds a lot of other things but all of them gonna be stored into the node modules on your roots type rectory so a simple style you can use and specifically install modules put your application in a very very simple in a minimalistic a way so I guess the pretty much god guys that was very very quick tutorial just explaining more how models work and how actually require works and how you can explore things between or export functions or dr types from one model to another in a very simple and minimalistic way so I think that's watching as you can I will catch you in the next one what about really going to do the Express server and just show you a very quick demo or a very quick example of how you can use no tears for creating a web server on your local machine so as I've said I will catch you in the next one
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from CoderOne · CoderOne · 22 of 60

1 Laravel CMS | N-01 | Getting Started and Environment Set Up
Laravel CMS | N-01 | Getting Started and Environment Set Up
CoderOne
2 Laravel CMS | N-02 | Routes, Controllers and Views
Laravel CMS | N-02 | Routes, Controllers and Views
CoderOne
3 Laravel CMS | N-03 | Dealing With Assets and Page Layouts
Laravel CMS | N-03 | Dealing With Assets and Page Layouts
CoderOne
4 Laravel CMS | N-04 | Migration, Models and Adding Categories
Laravel CMS | N-04 | Migration, Models and Adding Categories
CoderOne
5 Laravel CMS | N-05 | Showing Added Categories, and Session Messages
Laravel CMS | N-05 | Showing Added Categories, and Session Messages
CoderOne
6 Laravel CMS | N-06 | Edit\Remove Categories using AJAX and Popups
Laravel CMS | N-06 | Edit\Remove Categories using AJAX and Popups
CoderOne
7 Laravel CMS | N-07 | Add New Post
Laravel CMS | N-07 | Add New Post
CoderOne
8 Laravel CMS | N-08 | Creating a Basic Laravel Blog
Laravel CMS | N-08 | Creating a Basic Laravel Blog
CoderOne
9 HTML5 Canvas For Beginners | Getting Started | #01 with Webpack
HTML5 Canvas For Beginners | Getting Started | #01 with Webpack
CoderOne
10 HTML5 Canvas For Beginners | Drawing Basic Shapes | 02
HTML5 Canvas For Beginners | Drawing Basic Shapes | 02
CoderOne
11 HTML5 Canvas | Drawing Text With Circles | Part 01
HTML5 Canvas | Drawing Text With Circles | Part 01
CoderOne
12 HTML5 Canvas | Text Animation and Circle Collision | Part 02
HTML5 Canvas | Text Animation and Circle Collision | Part 02
CoderOne
13 Complete Guide To Web Development In 2018
Complete Guide To Web Development In 2018
CoderOne
14 AJAX & JSON Explained | Examples
AJAX & JSON Explained | Examples
CoderOne
15 Visual Studio Code Web Development Setup and Extensions
Visual Studio Code Web Development Setup and Extensions
CoderOne
16 Electron Build Desktop Apps HTML/CSS/JS - Getting Started 01
Electron Build Desktop Apps HTML/CSS/JS - Getting Started 01
CoderOne
17 Electron Build Desktop Apps HTML/CSS/JS | Creating Windows and Processes 02
Electron Build Desktop Apps HTML/CSS/JS | Creating Windows and Processes 02
CoderOne
18 Electron Build Desktop Apps HTML\CSS\JS | Dialog, Sessions and Cookies 03
Electron Build Desktop Apps HTML\CSS\JS | Dialog, Sessions and Cookies 03
CoderOne
19 Electron Build Desktop Apps HTML\CSS\JS | Custom App Menu & Context Menu 04
Electron Build Desktop Apps HTML\CSS\JS | Custom App Menu & Context Menu 04
CoderOne
20 Electron Build Desktop Apps HTML\CSS\JS | Package, Build and Deploy your App 05
Electron Build Desktop Apps HTML\CSS\JS | Package, Build and Deploy your App 05
CoderOne
21 Node.js Brief Beginners Introduction #01
Node.js Brief Beginners Introduction #01
CoderOne
Node.js How Modules Works & NPM #02
Node.js How Modules Works & NPM #02
CoderOne
23 Node.js Working With Events and Event Emitter #03
Node.js Working With Events and Event Emitter #03
CoderOne
24 Node.js File System (Read and Write) FS 04
Node.js File System (Read and Write) FS 04
CoderOne
25 Node.js Create a Basic Server Using Express 05
Node.js Create a Basic Server Using Express 05
CoderOne
26 Json Web Token Authentication JWT Explained Securing API
Json Web Token Authentication JWT Explained Securing API
CoderOne
27 CSS Flex Box Design | Practical Examples |
CSS Flex Box Design | Practical Examples |
CoderOne
28 API How It Works With Practical Examples
API How It Works With Practical Examples
CoderOne
29 MongoDB Getting Started 01
MongoDB Getting Started 01
CoderOne
30 MongoDB Working with APIs and Practical Examples
MongoDB Working with APIs and Practical Examples
CoderOne
31 Create a Command Line Interface (CLI) Using Node JS #01
Create a Command Line Interface (CLI) Using Node JS #01
CoderOne
32 Create a Command Line Interface (CLI) Using Node JS 02
Create a Command Line Interface (CLI) Using Node JS 02
CoderOne
33 Build React Apps | Introduction And Getting Started #01
Build React Apps | Introduction And Getting Started #01
CoderOne
34 Build React Apps | Working With Components And Multiple Rendering #02
Build React Apps | Working With Components And Multiple Rendering #02
CoderOne
35 Build React Apps | App State Management | Practical Examples #03
Build React Apps | App State Management | Practical Examples #03
CoderOne
36 Build React Apps | Getting Started With Flux (Intro) #04
Build React Apps | Getting Started With Flux (Intro) #04
CoderOne
37 Build React Apps | Create a Clock Timer Using React 05
Build React Apps | Create a Clock Timer Using React 05
CoderOne
38 Build React Apps | Create a Clock Timer Using React 05 | PART2|
Build React Apps | Create a Clock Timer Using React 05 | PART2|
CoderOne
39 CSS Preprocessors Getting Started | SASS and LESS | Practical Examples
CSS Preprocessors Getting Started | SASS and LESS | Practical Examples
CoderOne
40 Regex Introduction | Learn Regular Expressions 01
Regex Introduction | Learn Regular Expressions 01
CoderOne
41 PHP VS Node.js Which is Best For Web Development
PHP VS Node.js Which is Best For Web Development
CoderOne
42 Drag and Drop Using Native Javascript 01
Drag and Drop Using Native Javascript 01
CoderOne
43 Drag And Drop Using Native Javascript 02
Drag And Drop Using Native Javascript 02
CoderOne
44 Master Git (Version Control) in One Video From Scratch
Master Git (Version Control) in One Video From Scratch
CoderOne
45 Let's Learn The New Javascript ES6 Class Syntax
Let's Learn The New Javascript ES6 Class Syntax
CoderOne
46 Let's Create A BlockChain On Node.js
Let's Create A BlockChain On Node.js
CoderOne
47 Best Online Code Editors For Web Developers
Best Online Code Editors For Web Developers
CoderOne
48 Let's Create a Modern Login Form on React #01
Let's Create a Modern Login Form on React #01
CoderOne
49 Let's Create a Modern Login Form on React #02
Let's Create a Modern Login Form on React #02
CoderOne
50 Laravel CMS | N-09 | Admin Registration
Laravel CMS | N-09 | Admin Registration
CoderOne
51 Laravel CMS | N-10 | Login and Authentication
Laravel CMS | N-10 | Login and Authentication
CoderOne
52 Let's Create a Twitter Bot (Listen and Retweet)
Let's Create a Twitter Bot (Listen and Retweet)
CoderOne
53 Rapid Webpage Creation With Emmet (HTML & CSS)
Rapid Webpage Creation With Emmet (HTML & CSS)
CoderOne
54 Create Popups and Modals Using Native Javascript, HTML and CSS
Create Popups and Modals Using Native Javascript, HTML and CSS
CoderOne
55 Promises and Callbacks on Javascript With Practical Examples
Promises and Callbacks on Javascript With Practical Examples
CoderOne
56 Create Collapses using Native Javascript, HTML and CSS
Create Collapses using Native Javascript, HTML and CSS
CoderOne
57 Let's Learn Typescript (Javascript Devs) | Getting Started 01
Let's Learn Typescript (Javascript Devs) | Getting Started 01
CoderOne
58 Let's Learn Typescript | Interfaces and Generic Types (The Typing System) 02
Let's Learn Typescript | Interfaces and Generic Types (The Typing System) 02
CoderOne
59 Let's Learn Typescript | Work With Classes, Modules and Enums 03
Let's Learn Typescript | Work With Classes, Modules and Enums 03
CoderOne
60 Let's Learn Typescript | React and Webpack With TS 04
Let's Learn Typescript | React and Webpack With TS 04
CoderOne

This video teaches how Node.js modules work and how to use NPM to install and manage packages, with a focus on importing and exporting modules, and managing dependencies. It covers the basics of Node.js modules and NPM, and provides practical examples of how to use these tools. By the end of this video, viewers will be able to use Node.js modules and NPM to build and manage their own applications.

Key Takeaways
  1. Create a new file to represent a module
  2. Use the require function to import a module
  3. Use the exports keyword to make a module's functions available for import
  4. Install modules using npm install
  5. Save dependencies using --save and dev dependencies using --save-dev
💡 The require function and exports keyword are used to import and export modules in Node.js, while NPM is used to install and manage packages, including dependencies and dev dependencies.

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →