Learn How to Instantly Install a Specific Version of an NPM Package!
Updated on Jul 10, 2025 | 11 min read | 21.91K+ views
Share:
For working professionals
For fresh graduates
More
Updated on Jul 10, 2025 | 11 min read | 21.91K+ views
Share:
Table of Contents
Did You Know? The npm registry is a colossal ocean with over 3 million JavaScript packages as of today? That makes it the world's largest single-language code hub!
To install a specific version of NPM package, use the npm install command followed by the package name and version number, like this: npm install package@version. For front-end developer projects, managing dependencies this way helps maintain consistency, especially when integrating Java-based APIs or microservices into portfolio websites or interactive apps.
This blog will guide you through the steps to install specific NPM versions, check for available versions, and provide tips for effective dependency management.
JavaScript is crucial for scalable apps, and NPM helps manage dependencies. upGrad’s Software Engineering Courses provide training in JavaScript, system architecture, and core programming to build reliable software. Enroll today!
Getting an NPM install-specific version using the command line is a straightforward process. Here’s a step-by-step guide:
NPM install <package-name>@<version>
NPM install lodash@4.17.21
Your specific version of an NPM package using the command line is ready now!
Improve your programming skills with courses on tools like NPM, covering techniques to manage dependencies, use AI, and build scalable applications, such as:
After installing, you can also specify the version directly within your project by updating the package.json file.
Also read: Top Front-End Developer Interview Questions for 2025
Installing a specific version of NPM package can also be done by specifying the version directly in your project’s package.json file. This method ensures that your project always installs the exact version you need, even when running npm install on different machines or environments. Here's how you can do it:
Add or update the entry for the package with the desired version number. For example:
"dependencies": {
"lodash": "4.14.1"
}
In this example, the lodash package is specified with version 4.14.1. This will ensure that every time you run npm install, the specific version of NPM package you’ve defined will be installed, providing consistency across different setups or team environments.
NPM-install
This command will read the package.json file and install the specified versions of the packages listed in the “dependencies” and “devDependencies” sections
Also read: How to Install Dev Dependencies in npm? A Complete Guide to Dependencies & Scripts
After updating the package.json file, you can install a specific version using the Yarn CLI.
The process of installing a specific version of NPM package using Yarn CLI is very simple and ensures you get the exact version you need for your project. Here’s a more detailed explanation of the steps:
To install a specific version of NPM package with Yarn, use the following command format:
yarn add <package-name>@<version>
Replace <package-name> with the name of the package you want to install, and <version> with the specific version number you need. For example, to install version 4.17.21 of the lodash package, you would run:
yarn add lodash@4.17.21
Using this method, you can easily manage dependencies and ensure your project is using the specific version of NPMpackage that is compatible with your project’s requirements.
Also Read: Full Stack Developer Salary in India 2025: Trends & Top Recruiters
After installing a specific version with Yarn CLI, you can also install a package directly from GitHub for more customized versions.
To install packages available at GitHub Packages and configure your project to use them, follow these steps:
Create or edit a .NPMrc file within the same directory as the package.json file. Add the following line, replacing NAMESPACE with the account name that owns the repository where your project is hosted:
@NAMESPACE:registry=https://NPM.pkg.github.com
This configuration sets GitHub Packages as the registry for your project.
In the “dependencies” section of your package.json, add the package and define the desired version:
"dependencies": {
"ORGANISATION_NAME/PACKAGE_NAME": "1.1.4"
}
Run the following command to install the package and its dependencies:
$ NPM install
Become a sought-after developer with the 9-month Full Stack Development Course by IIITB. Gain hands-on experience, learn top programming tools, and work on real-world projects. Apply Now to upskill and unlock exclusive job portal access and IIITB alumni status.
Also read: 25+ Essential Machine Learning Projects GitHub with Source Code for Beginners and Experts in 2025
Once you've installed from GitHub, understanding semantic versioning helps manage package versions for better compatibility.
Semantic versioning is a widely used versioning scheme for software packages, including specific version of NPMpackages, that follows the format MAJOR.MINOR.PATCH. Each segment of the specific version of NPM package number represents a specific type of change in the software:
Understanding specific version of NPM package helps developers manage and maintain compatibility when updating dependencies, ensuring that the correct versions are used and that the software works as intended across different environments.
Semantic versioning helps developers and users of a package understand the significance of version updates at a glance.
When installing packages, you can specify the desired level of version flexibility using semantic versioning operators:
You have the flexibility to specify which types of updates your package can accept from its dependencies by using semantic versioning in your package.json file.
To indicate the acceptable version ranges, you can implement the following syntax:
Also read: What is Agile Software Development? Methodologies & Principles
With semantic versioning in place, let's explore the importance of installing specific versions of NPM packages.
Installing specific versions of node holds significant importance as it facilitates the distribution of JavaScript code to web and mobile applications while allowing ongoing improvements without requiring users to delete and update their apps.
Let’s understand the importance of installing specific packages –
Stay competitive in AI-driven software development by upskilling with a Master’s in Artificial Intelligence and Machine Learning from IIIT Bangalore & LJMU. Gain hands-on experience in integrating AI models, chatbots, and automation into applications, while mastering Deep Learning, Generative AI, and NLP.
Let us now have a closer look at some of the best practices for installing NPM packages.
Also read: SDLC Guide: The 7 Key Software Development Life Cycle Phases Explained
Installing the specific version of NPM package is crucial for maintaining stability, preventing unexpected bugs, and ensuring compatibility across different environments.
By using the correct specific version of NPM package, you can avoid issues caused by automatic updates or mismatched dependencies.
Here are some reliable methods and tips to help you install the specific version of NPM packages with confidence:
By following these methods, you'll be able to confidently install the specific version of NPM packages, ensuring compatibility and preventing issues in your projects.
Also Read: Top Full Stack Developer Skills to Master in 2025
Once you've followed best practices for installing specific NPM versions, let's look at how to troubleshoot common installation issues.
To install a specific version of NPM package, use the command npm install [package]@[version]. This ensures project stability and compatibility by preventing unexpected bugs. Make it a habit to specify versions in your package.json file to avoid conflicts and maintain consistency.
A lot of users face dependency issues when installing NPM packages. upGrad’s courses teach you how to manage specific NPM versions and other advanced techniques, helping you build stable, scalable software with expert guidance.
Feeling unsure about where to begin with your software career? Connect with upGrad’s expert counselors or visit your nearest upGrad offline centre to explore a learning plan tailored to your goals. Transform your programming journey today with upGrad!
Boost your career with our popular Software Engineering courses, offering hands-on training and expert guidance to turn you into a skilled software developer.
Master in-demand Software Development skills like coding, system design, DevOps, and agile methodologies to excel in today’s competitive tech industry.
Stay informed with our widely-read Software Development articles, covering everything from coding techniques to the latest advancements in software engineering.
References :
https://www.mend.io/wp-content/media/2021/02/1-1-1024x260.png
https://youtu.be/rg5BE2glE6U?t=228
https://user-images.githubusercontent.com/27772165/54670414-e621e480-4af3-11e9-871d-80af39fe32de.png
https://www.youtube.com/watch
https://builtin.com/software-engineering-perspectives/npm
900 articles published
Director of Engineering @ upGrad. Motivated to leverage technology to solve problems. Seasoned leader for startups and fast moving orgs. Working on solving problems of scale and long term technology s...
Get Free Consultation
By submitting, I accept the T&C and
Privacy Policy
India’s #1 Tech University
Executive PG Certification in AI-Powered Full Stack Development
77%
seats filled
Top Resources