How to Install Specific Version of NPM Package?
Updated on Apr 16, 2025 | 9 min read | 21.2k views
Share:
For working professionals
For fresh graduates
More
Updated on Apr 16, 2025 | 9 min read | 21.2k views
Share:
Table of Contents
NPM (Node Package Manager) empowers 17 M+ developers globally, ensuring elegant, productive, and secure JavaScript development. Complemented by advanced tools and services, NPM takes developers’ work to new heights. Just being able to install a specific version of the NPM package can help make your entire process of coding much simpler.
In this article, we will help you provide yourself with the knowledge and techniques needed to learn how to install a specific version of Node confidently.
Level up your JavaScript development—explore Artificial Intelligence & Machine Learning Courses and understand how tools like Node Package Manager integrate with modern ML workflows.
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 –
Master Version Control & Boost Your Tech Skills! Explore these programs to deepen your understanding of NPM, version management, and the power of AI-driven development:
You can use the ‘NPM view’ command followed by the package name and the keyword ‘versions’ to check for available versions. Here’s an example:
NPM view <package-name> versions
For instance, if you want to see the available versions of the package “lodash,” you would run:
NPM view lodash versions
This command will display a list of available versions, such as ‘1.0.0‘, ‘1.1.0‘, ‘2.0.0‘, and so on. You can use this information to determine which specific version you want to install or to check if you have the latest version already installed.
If you want to view the latest stable version, you can use
NPM view <package name> version
For example, the NPM view gulp version will provide the output 4.0.2, indicating the latest stable version of gulp.
Check Out upGrad’s Software Development Courses to upskill yourself.
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!
Installing specific version of NPM
Installing a specific version of an NPM package can also be done by specifying the version in the package.json file of your project. Here’s how you can do it:
“dependencies”: {
“lodash”: “4.14.1”
}
This specifies that you want to install version 4.14.1 of the lodash package.
Installing NPM with package.json
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.
The process of installing a specific version of the NPM package using Yarn CLI is very simple –
yarn add <package-name>@<version>
yarn add lodash@4.17.21
This command will install version 4.17.21 of the lodash package.
To install packages available at GitHub Packages and configure your project to use them, follow these steps:
@NAMESPACE:registry=https://NPM.pkg.github.com
This configuration sets GitHub Packages as the registry for your project.
“dependencies”: {
“ORGANISATION_NAME/PACKAGE_NAME”: “1.1.4”
}
$ NPM install
Learn in-depth software engineering skills with upGrad’s Executive Post Graduate Programme in Software Development – Specialisation in Full Stack Development.
Semantic versioning is a widely adopted versioning scheme for software packages that follows a specific format: MAJOR.MINOR.PATCH. Each segment conveys a specific meaning:
MAJOR version: When you make incompatible API changes or introduce major functionality changes, you increment the MAJOR version. This indicates that the new version may not be backwards compatible with the previous versions.
MINOR version: Incrementing the MINOR version occurs when new features or functionality are added while ensuring compatibility with previous versions. This signifies that the updated version remains backwards compatible with earlier releases.
PATCH version: When you make backwards-compatible bug fixes or minor updates, you increment the PATCH version. This indicates that the new version does not introduce new features or break changes.
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:
Here’s your chance to become a pro software developer with Full Stack Software Development Bootcamp by upGrad!
Use npm –version to check the version of the NPM CLI.
Use npm list –depth=0 to get detailed version information of NPM, current package, Node.js, and other direct dependencies.
Use npm help <command> to access the built-in help functionality of NPM.
Use npm init –yes to quickly create a package.json file with default values.
Set default values for the author name and email using npm config set init.author.name and npm config set init.author.email commands.
Utilise websites like NPMs.io to explore and evaluate NPM packages based on quality, popularity, and maintenance metrics.
Install and save a package using npm install <package-name> –save.
Configure NPM to save dependencies with different prefixes or exact versions using npm config set save-prefix and npm config set save-exact.
Installing a specific version of an NPM package can be a valuable skill for developers. Whether you need to maintain compatibility with a certain package version or troubleshoot issues caused by updates, NPM provides a straightforward solution. This flexibility empowers developers to have greater control over their project dependencies and ensures a smooth development experience. So, the next time you need a specific version of an NPM package, remember that NPM has got you covered with its version-specific installation capabilities!
With upGrad’s Master of Science in Computer Science, students can learn all the in-demand skills and ascend in their Software Development careers. With AI-powered, immersive learning experiences, you are just a click away from emerging as a leading developer!
Enrol now to become a pro in software engineering!
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