3 min read
•Question 6 of 62easyWhat is NPM and how does it work?
Understanding Node Package Manager.
What You'll Learn
- What NPM is
- Key commands
- package.json basics
What is NPM?
NPM (Node Package Manager) is the default package manager for Node.js. It helps you install, share, and manage dependencies.
Key Commands
$ terminalBash
# Initialize project
npm init -y
# Install package
npm install express
npm i express # shorthand
# Install dev dependency
npm install -D nodemon
# Install globally
npm install -g typescript
# Uninstall
npm uninstall express
# Update packages
npm update
# Run scripts
npm run dev
npm start
npm testpackage.json
data.jsonJSON
{
"name": "my-app",
"version": "1.0.0",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"nodemon": "^3.0.0"
}
}