Lesson 16 of 30
NPM Packages
53% complete
Chapters
Chapter 16
NPM Packages
Learn how to install and use external packages in Node.js.
Theory
NPM packages are reusable libraries published for JavaScript and Node.js applications.
Packages can provide functionality such as:
• Web servers
• Authentication
• Validation
• Database connectivity
• Logging
• Testing
Packages are usually installed using npm install.
Example
Node.js Example
npm install express
npm install dotenv
npm install mongooseOutput
The selected packages are added to the Node.js project.
Practice
Install Express and another useful NPM package in a test project.
Interview Questions
1.
What is an NPM package?
2.
How do you install an NPM package?
3.
Where are installed dependencies recorded?
Quick Quiz
Which option best matches this chapter?
A.Reusable JavaScript functionality
B.Only image files
C.Only database records
D.Only CSS files
Answer: Reusable JavaScript functionality