- Home
- Services
- IVY
- Portfolio
- Game Dev
- Blogs
- About Us
- Contact Us
- Sun-Tue (9:00 am-7.00 pm)
- infoaploxn@gmail.com
- +91 656 786 53
This guide will walk you through the essentials: package.json, installing packages, managing dependencies, and a few pro tips.
What is npm?
npm is both:
- A package manager: It lets you install and manage libraries (packages) for your project.
- A registry: A massive online repository where developers publish packages for others to use.
It comes bundled with Node.js, so you don’t need to install it separately. Check the version with:
npm -v
Understanding package.json
At the heart of every Node project is the package.json file. It describes your project and tracks its dependencies.
Create one by running:
npm init
You’ll be asked a series of questions. To skip and create a default file:
npm init -y
A typical package.json looks like this:
{
"name": "my-app",
"version": "1.0.0",
"description": "A sample Node.js project",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "Your Name",
"license": "MIT",
"dependencies": {
"express": "^4.18.2"
},
"devDependencies": {
"nodemon": "^3.0.1"
}
}
Installing Packages
To add a package:
npm install <package-name>
Example:
npm install express
This does two things:
1. Downloads the package into a node_modules/ folder.
2. Adds an entry under dependencies in package.json.
Dev Dependencies:
Sometimes you only need a package for development. Example with nodemon:
npm install nodemon --save-dev
Dependencies Explained
- dependencies: Required for your app to run.
- devDependencies: Needed only during development.
- peerDependencies: Specify compatible versions your project expects.
- optionalDependencies: App should still work if these fail.
Common npm Commands
npm install # Install all dependencies
npm install <pkg> # Install a new package
npm uninstall <pkg> # Remove a package
npm update # Update all packages
npm outdated # Check outdated packages
npm run <script> # Run a script from package.json
Example of custom script in package.json:
{
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
}
}
Then run:
npm run dev
The package-lock.json File
Whenever you install dependencies, npm creates/updates a package-lock.json. It locks exact versions and ensures consistency across environments. Always commit it to version control.
Global vs Local Installs
By default, npm install installs locally. For CLI tools you want system-wide:
npm install -g nodemon
Check where global packages are installed:
npm root -g
Pro Tips
1. Use npx to run packages without global installs:
npx create-react-app my-app
2. Keep dependencies clean:
npm prune
3. Check security issues:
npm audit
4. Use npm ci in CI/CD pipelines for clean installs.
Final Thoughts
npm is more than just a package installer—it’s the glue that holds your Node.js projects together. Understanding package.json, dependencies, and the most common commands will save you time and headaches. As your projects grow, npm scripts and best practices around dependencies will help you stay organized and ship faster.
Imagine reducing your operational costs by up to $100,000 annually without compromising on the technology you rely on. Through our partnerships with leading cloud and technology providers like AWS (Amazon Web Services), Google Cloud Platform (GCP), Microsoft Azure, and Nvidia Inception, we can help you secure up to $25,000 in credits over two years (subject to approval).
These credits can cover essential server fees and offer additional perks, such as:
By leveraging these credits, you can significantly optimize your operational expenses. Whether you're a startup or a growing business, the savings from these partnerships ranging from $5,000 to $100,000 annually can make a huge difference in scaling your business efficiently.
The approval process requires company registration and meeting specific requirements, but we provide full support to guide you through every step. Start saving on your cloud infrastructure today and unlock the full potential of your business.

