Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • NodeJS Tutorial
  • NodeJS Exercises
  • NodeJS Assert
  • NodeJS Buffer
  • NodeJS Console
  • NodeJS Crypto
  • NodeJS DNS
  • NodeJS File System
  • NodeJS Globals
  • NodeJS HTTP
  • NodeJS HTTP2
  • NodeJS OS
  • NodeJS Path
  • NodeJS Process
  • NodeJS Query String
  • NodeJS Stream
  • NodeJS String Decoder
  • NodeJS Timers
  • NodeJS URL
  • NodeJS Interview Questions
  • NodeJS Questions
  • Web Technology
Open In App
Next Article:
How to list npm user-installed packages in Node.js?
Next article icon

How to install modules without npm in node.js ?

Last Updated : 05 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

We can install modules required for a particular project in node.js without npm, the recommended node package manager using yarn. Yarn is a wonderful package manager. Like npm, if you have a project folder with package.json containing all the required dependencies mentioned for the project, you can use yarn to install all the dependencies.

 

1. How to install yarn? 
 

To install yarn, visit the official installation page of yarn (https://classic.yarnpkg.com/en/docs/install). The page will automatically detect the operating system you are using. Additional installation instructions are also mentioned in the installation page. Once you have followed the steps on the installation manager and the installation process is complete, type the following command in the ternimal/ command prompt.

 

yarn --version 

 

This should show the particular version you are using in you computer. For example: 1.22.5 . Now that we have installed yarn, lets see how we use yarn in our projects.

2. How to use yarn to install projects? 
 

To use yarn, go to the folder where the modules are needed to be installed. If it is not initialized with yarn, run the yarn init command. It will ask some questions regarding the project to create the package.json file. The package.json file is the most important file as it contains the necessary modules that are required by your project. Anyone with the package.json file, can run some commands( we will discuss this later) to install all the dependencies required by your project. You will get a similar question when you run yarn init command:

 

question name (testdir): my-awesome-package  question version (1.0.0):  question description:       The best package you will ever find.  question entry point (index.js):  question git repository:       https://github.com/yarnpkg/example-yarn-package  question author: Yarn Contributor  question license (MIT):  question private:  success Saved package.json  Done in 87.70s.

 

After this is done, a package, json file is created. If you open the package.json file, it should look something like this:

 

{       "name": "my-awesome-package",       "version": "1.0.0",       "description": "The best package you will ever find.",       "main": "index.js",       "repository": {             "url": "https://github.com/yarnpkg/example-yarn-package",             "type": "git"       },       "author": "Yarn Contributor",       "license": "MIT"  }

 

Alternatively, if you have a project that contains a  package.json file from the beginning, you can use yarn or yarn install command to install all the mentioned dependencies from the package.json file.

 

Note: If you do not want to answer all the questions when performing yarn init command (although not recommended), you can use yarn init -y command to initialise it with the default values. You can change the details by editing the package.json file with suitable text editor. 

3. Installing packages in the project folder 
 

Now we shall see how we can install packages using yarn. Suppose we want to install the package named express. We would enter the following command to install express: 

 

// Command to install express to the current project folder  yarn add express      // Command to install express globally in your machine  yarn global add expres     // This is the most generalized way, Just replace    // the <package-name> with the name of the package  yarn add <package-name> 

 

Note: The global keyword is used to inform yarn that we want to install express globally. 

Reference: There are a lot more commands that you can execute with yarn. A list of commands is mentioned in the following link: https://classic.yarnpkg.com/en/docs/cli 

If you are migrating from npm to yarn, you can use this cheatsheet to know the similar commands for yarn. 

 



Next Article
How to list npm user-installed packages in Node.js?

A

ankurkayalcse
Improve
Article Tags :
  • How To
  • Installation Guide
  • Node.js
  • Web Technologies
  • how-to-install
  • Node.js-Misc

Similar Reads

  • How to Install NPM FS in Node JS ?
    The file system module allows you to work with the file system on your computer NodeJS includes the fs module, to communicate with file systems. It provides functionality for interacting with the file system, such as reading from and writing to files, creating and removing directories, etc. The File
    4 min read
  • How to list npm user-installed packages in Node.js?
    What is Node.js? Node.js is an open source and cross-platform runtime environment for executing JavaScript code outside of a browser. Click here for more. What is npm? Here, "npm" stands for "Node Package Manager" which is the package manager for Node.js and serves as a command-line utility for inte
    2 min read
  • How to Install Node.js on Windows
    Installing Node.js on Windows is a straightforward process, but it's essential to follow the right steps to ensure smooth setup and proper functioning of Node Package Manager (NPM), which is crucial for managing dependencies and packages. This guide will walk you through the official site, NVM, Wind
    6 min read
  • How to Install Node.js and npm on Ubuntu?
    If you're developing JavaScript applications on Ubuntu, knowing how to install Node.js on Ubuntu is essential. Node.js is a powerful runtime environment that enables server-side scripting, while npm, the Node Package Manager, allows you to manage your project's dependencies easily. This guide will w
    7 min read
  • How to Install Node.js on Linux
    Installing Node.js on a Linux-based operating system can vary slightly depending on your distribution. This guide will walk you through various methods to install Node.js and npm (Node Package Manager) on Linux, whether using Ubuntu, Debian, or other distributions. PrerequisitesA Linux System: such
    6 min read
  • How To Install A Local Module Using NPM?
    To install a local module using npm, it's important to understand how npm (Node Package Manager) works with local packages. npm allows you to manage and install various JavaScript packages and modules, whether they’re from a remote repository or locally on your system. Installing a local module is p
    3 min read
  • How to Install NodeJS on MacOS
    Node.js is a popular JavaScript runtime used for building server-side applications. It’s cross-platform and works seamlessly on macOS, Windows, and Linux systems. In this article, we'll guide you through the process of installing Node.js on your macOS system. What is Node.jsNode.js is an open-source
    7 min read
  • How To Use Node Modules with npm and package.json
    NodeJS is a powerful runtime for server-side JavaScript & these modules are reusable pieces of code that can be easily imported and used in NodeJS applications. npm (Node Package Manager) is the default package manager for Node JS and is used to install, manage, and publish NodeJS packages. This
    3 min read
  • What is File System Module in Node.js ?
    Node.js is a powerful platform for building server-side applications, and one of its key features is its ability to interact with the file system. The File System (fs) module in Node.js provides an extensive API to work with files and directories, allowing developers to perform operations such as re
    3 min read
  • How to Install Node & Run NPM in VS Code?
    Node.js is an open-source, server-side JavaScript runtime environment built on the V8 engine. It allows developers to execute JavaScript code outside of a web browser. In this article, we will see how to install Node.js and NPM and install packages in VS Code using NPM. Steps to Install NodeJS and N
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences