Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

How to Install Specific Version of NPM Package?

Updated on 05 June, 2023

20.29K+ views
10 min read

Introduction to installing specific version of NPM package

NPM (Node Package Manager) empowers 17M+ 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 equip yourself with the knowledge and techniques needed to learn how to install a specific version of node confidently.

Understanding the importance of installing specific versions

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 – 

  • Ensure Code Sharing: Specific version installations enable seamless sharing with other NPM users worldwide, promoting collaboration and accelerating development processes.
  • Version Management: Installing specific versions allows developers to create and manage multiple versions of code, empowering them to test and evaluate different versions to determine the one that works best for their projects.
  • Performance Optimisation: By installing specific versions, developers can easily send minor updates to keep the software running at its optimal performance level, ensuring continuous improvements without disrupting user experiences.
  • Seamless Rollouts: Installing specific NPM versions facilitates the smooth rollout of improvements, allowing developers to introduce enhancements without interrupting or causing damage to the user experience.

Check out our free technology courses to get an edge over the competition.

Checking available versions of an NPM package

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.

Installing specific version using NPM command line

Getting an NPM install specific version using the command line is a straightforward process. Here’s a step-by-step guide:

  1. Open your command-line interface (CLI) or terminal.
  2. Navigate to the root directory of your project or the location where you want to install the package.
  3. Use the following command to install a node install specific version:

NPM install <package-name>@<version>

  1. Replace <package-name> with the package name you want to install and <version> with your desired specific version. For example:

NPM install lodash@4.17.21

  1. This command will install version 4.17.21 of the lodash package.
  2. Wait for the installation process to complete. NPM will fetch and install the package’s specified version and dependencies.

Your specific version of an NPM package using the command line is ready now!

Installing specific version of NPM

Installing specific version using package.json file

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:

  • Open the package.json file located in the root directory of your project.
  • Locate the “dependencies” or “devDependencies” section, depending on whether the package is a production or development dependency.
  • Add or update the entry for the package with the desired version number. For example:

“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

  • Save the package.json file.
  • Open your command-line interface (CLI) or terminal.
  • Navigate to the root directory of your project.
  • Run the following command to install the dependencies:

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.

NPM install via package. json

Install Specific Version of NPM Package using Yarn CLI

The process of installing a specific version of the NPM package using Yarn CLI is very simple – 

  • Open your command-line interface (CLI) or terminal.
  • Navigate to your project’s root directory or the location where you want to install the package.
  • Use the following command to install a specific version of an NPM package with Yarn:

yarn add <package-name>@<version>

  • Replace <package-name> with the package name you aim to install and <version> with the specific version you desire. For example:

yarn add lodash@4.17.21

This command will install version 4.17.21 of the lodash package.

  • Wait for the installation process to complete. Yarn will fetch and install the package’s specified version and dependencies.

Installing NPM using Yarn CLI

Install Specific Version of NPM Package from GitHub

To install packages available at GitHub Packages and configure your project to use them, follow these steps:

  • Ensure that you have a package.json file within your project directory. If not, create one. This file will manage your project’s dependencies.
  • Authenticate GitHub Packages using the appropriate authentication method. This step ensures you have permission to access and install packages from GitHub Packages.
  • 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.

  • Add the .NPMrc file to your repository so that GitHub Packages can easily locate and use it.
  • Configure your package.json file to include the specific package you want to install. Define the full-scoped package title for GitHub Packages, such as @my-org/package, or the full name of the packages from NPMjs.com, such as @babel-core or lodash.
  • In the “dependencies” section of your package.json, add the package and define the desired version:

“dependencies”: {

  “ORGANISATION_NAME/PACKAGE_NAME”: “1.1.4”

}

  • Save the changes to your package.json file.
  • Run the following command to install the package and its dependencies:

$ NPM install

Learn in-depth software engineering skills with upGrad’s Executive Post Graduate Programme in Software Development – Specialisation in Full Stack Development

Using semantic versioning for package versioning

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

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:

  • ^ (caret)
  • ~ (tilde)
  • = (equal)

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:

  • For patch releases: Use 1.0 or 1.0.x or ~1.0.4 to allow updates up to version 1.0.4.
  • For minor releases: Use 1 or 1.x or ^1.0.4 to allow updates within the 1.x.x range, but not to version 2.0.0.
  • For major releases: Use * or x to allow any major version updates.

Here’s your chance to become a pro software developer with Full Stack Software Development Bootcamp by upGrad!

Best practices for installing specific versions of NPM packages

  • Checking NPM version:

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.

  • Getting help:

Use npm help <command> to access the built-in help functionality of NPM.

  • Starting new projects with NPM init:

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.

  • Finding NPM packages:

Utilise websites like NPMs.io to explore and evaluate NPM packages based on quality, popularity, and maintenance metrics.

  • Saving dependencies:

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.

Troubleshooting common issues during installation

  1. Random Errors: Unidentifiable issues can be initially resolved by running the npm cache clean and then trying the installation again. Use the – verbose option if you need additional details about the error.
  2. No Compatible Version Found: If you encounter this error, you have an outdated version of NPM. Update to the latest stable version of NPM.
  3. Permissions Errors: Refer to resources on how to download and install Node.js and resolve EACCES permissions errors when installing packages globally. 
  4. NPM Login Errors: If npm login fails, ensure that your email address on npmjs.com matches the email address you provide during login. 
  5. No Space: If you encounter an ENOSPC error, you attempt to install something on a drive with insufficient space or lack of write permissions. To resolve this, you can free up disk space or configure the tmp folder to a location with more available space by using the command npm config set tmp /path/to/big/drive/tmp.

Conclusion

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!

Frequently Asked Questions (FAQs)

1. Can I install multiple versions of an NPM package?

No, NPM only allows one package version to be installed globally. However, you can install different versions for different projects by specifying the version in each package.json file.

RELATED PROGRAMS