Close Menu
Soshace Digital Blog

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    What's Hot
    Interview

    How to Prepare for Your First Coding Job Interview?

    Programming

    Уроки React . Урок 10.

    Development

    Mastering IoT Development: A Strategic Guide for Professionals

    Important Pages:
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Today's Picks:
    • Scaling Success: Monitoring Indexation of Programmatic SEO Content
    • Leveraging Influencers: Key Drivers in New Product Launches
    • How Privacy-First Marketing Will Transform the Industry Landscape
    • The Impact of Social Proof on Thought Leadership Marketing
    • Balancing Value-Driven Content and Promotional Messaging Strategies
    • Top Influencer Marketing Platforms to Explore in 2025
    • Emerging Trends in Marketing Automation and AI Tools for 2023
    • Strategies to Mitigate Duplicate Content in Programmatic SEO
    Wednesday, December 17
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Soshace Digital Blog
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Services
    • SaaS & Tech

      Maximizing Efficiency: How SaaS Lowers IT Infrastructure Costs

      August 27, 2025

      Navigating Tomorrow: Innovations Shaping the Future of SaaS

      August 27, 2025

      Maximizing Impact: Strategies for SaaS & Technology Marketing

      August 27, 2025
    • AI & Automation

      Enhancing Customer Feedback Analysis Through AI Innovations

      August 27, 2025

      Navigating the Impact of AI on SEO and Search Rankings

      August 27, 2025

      5 Automation Hacks Every Home Service Business Needs to Know

      May 3, 2025
    • Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      August 27, 2025

      Analyzing Future Fintech Marketing Trends: Insights Ahead

      August 27, 2025

      Navigating the Complex Landscape of Finance and Fintech Marketing

      August 27, 2025
    • Legal & Compliance

      Exploring Thought Leadership’s Impact on Legal Marketing

      August 27, 2025

      Maximizing LinkedIn: Strategies for Legal and Compliance Marketing

      August 27, 2025

      Why Transparency Matters in Legal Advertising Practices

      August 27, 2025
    • Medical Marketing

      Enhancing Online Reputation Management in Hospitals: A Guide

      August 27, 2025

      Analyzing Emerging Trends in Health and Medical Marketing

      August 27, 2025

      Exploring Innovative Content Ideas for Wellness Blogs and Clinics

      August 27, 2025
    • E-commerce & Retail

      Strategic Seasonal Campaign Concepts for Online and Retail Markets

      August 27, 2025

      Emerging Trends in E-commerce and Retail Marketing Strategies

      August 27, 2025

      Maximizing Revenue: The Advantages of Affiliate Marketing for E-Commerce

      August 27, 2025
    • Influencer & Community

      Leveraging Influencers: Key Drivers in New Product Launches

      August 27, 2025

      Top Influencer Marketing Platforms to Explore in 2025

      August 27, 2025

      Key Strategies for Successful Influencer Partnership Negotiations

      August 27, 2025
    • Content & Leadership

      The Impact of Social Proof on Thought Leadership Marketing

      August 27, 2025

      Balancing Value-Driven Content and Promotional Messaging Strategies

      August 27, 2025

      Analyzing Storytelling’s Impact on Content Marketing Effectiveness

      August 27, 2025
    • SEO & Analytics

      Scaling Success: Monitoring Indexation of Programmatic SEO Content

      August 27, 2025

      Strategies to Mitigate Duplicate Content in Programmatic SEO

      August 27, 2025

      Effective Data Visualization Techniques for SEO Reporting

      August 27, 2025
    • Marketing Trends

      How Privacy-First Marketing Will Transform the Industry Landscape

      August 27, 2025

      Emerging Trends in Marketing Automation and AI Tools for 2023

      August 27, 2025

      Maximizing ROI: Key Trends in Paid Social Advertising

      August 27, 2025
    Soshace Digital Blog
    Blog / JavaScript / Node.js / Node.js Lessons / Node.js Lesson 3: Node Package Manager
    Beginners

    Node.js Lesson 3: Node Package Manager

    Mohammad Shad MirzaBy Mohammad Shad MirzaSeptember 14, 2020No Comments5 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Node.js Lesson 3: Node Package Manager
    Node.js Lesson 3: Node Package Manager
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link
    Node.js Lesson 3: Node Package Manager
    Node.js Lesson 3: Node Package Manager

    Hello everyone, we are going to learn about Node Package Manager (NPM) in this lesson. We talked slightly about it in Lesson 1 and initialized the project. Let’s dive deep now.

    What is NPM

    As the name suggests, it’s a Package Manager for Node. Open Source Developers from all around the globe can publish their Node packages and use the packages published by other people for free.

    It is an online repository for the publishing of open-source Nodejs projects.

    It is also a command-line utility to interact with packages in a Nodejs project and manage dependencies. The dependencies are just the packages that are being used in the project. npm cli helps easily install and remove the packages available on the npm registry.

    It helps us rapidly build software with the help of the 1,372k+ packages present on the npm registry. If you’re stuck with a problem, chances are there is already a solution contributed by someone which you can directly.

    NPM comes with standard Node installation. We already have a cli to interact with npm packages. You can check by running npm –version in the terminal. Now let’s understand how it works and how can we create a package ourselves.

    How to create a module and share it with community

    Suppose you have created a package and you want to share it on npm as a package. To keep things basic, let’s consider this is your awesome package:

    // index.js
    module.exports = function(){
        console.log("My awesome module at so share");
    }

    To share this package on NPM, you will have to initialize the repository as an npm package. To do that, you simply have to run one command:

    npm init

    The cli will ask you a bunch of questions regarding package name, version, author, etc and generate a package.json file. It is the same file that is used to track the package version too.

    {
      "name": "supermodule",
      "version": "1.0.0",
      "description": "ERROR: No README data found!",
      "main": "index.js",
      "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
      },
      "author": "Your name here",
      "license": "ISC",
      "repository": ""
    }

    Now we are ready to publish your awesome package.

    Read More:  Operating Systems Showdown: Windows vs. macOS vs. Linux for Web Development

    We are naming our package “supermodule”

    How to Publish

    You will need an npm account to publish your package. If you don’t have already, visit the signup page and create an account.

    Once you’re done, open terminal and login with your account using:

    npm login

    You’ll have to enter your username, email, and password to login successfully. Finally, enter this command to publish your package:

    npm publish
    

    Make sure your package name is unique.

    Congratulations, you have published your first package 🎉. You can type npm help to list down all the npm commands.

    How to install a node package

    Now we will talk about how someone can install and use your package in their project. The person simply has to type npm install followed by the package name he wants. For our example, it will be:

    npm install supermodule

    NPM will download the package and save it inside the npm_modules directory. This directory is the default place to save all the installed packages in a project.

    Now the developer doesn’t have to type the full path to the module. NPM checks if the package is present in the node_modules folder and easily imports it into the file:

    import SuperModule = require('supermodule');

    Good job, you have helped someone solve their problem using your awesome package. This is how Open Source Community helps each other and by publishing your package, you have become a part of it 🎉.

    What if the package is no longer needed and you want to uninstall it? You just to type this command in terminal and it will remove your package:

    npm remove "PACKAGE NAME"

    Enter the PACKAGE NAME that you want to remove.

    You can see the meta of the published package by visiting this url:

    http://registry.npmjs.org/supermodule

    Here, you can see all information on the module and its package.json including a link to the module file is contained. This file is also in the database. It was downloaded there automatically in a process of the npm publish command. Note that everything contained in this registry has public access.

    Read More:  Finding the Best Way to Learn JavaScript

    NPM does offer you to publish packages with limited access if you want to limit the usage. It is however paid and you can read more about the pricing on their official page.

    Here, we are providing the path of the module so it’s straight forward. Node will look for the package at the specified location and import it.

    Note: .js is optional. If .js is not present, Node will look either for user.js or user/index.js.

    But what will happen when we don’t provide the path? Example:

    const fs = require('fs');

    At first, Nodejs will see if the required module is a core module. Core modules are modules that are bundled with Nodejs by default. They are present in the /lib directory of your system and takes precedence over everything else. Some of the core modules are fs, https, etc.

    If the module identifier passed to require() is not a core module, and does not begin with ‘/’, ‘../’, or ‘./’, then Nodejs starts at the parent directory of the current module, and adds /node_modules, and attempts to load the module from that location.

    If the package is not found in either of the places mentioned above, Node will start looking for them in global packages. If the NODE_PATHenvironment variable is set to a colon-delimited list of absolute paths, then Node.js will search those paths for modules if they are not found elsewhere.

    Additionally, Node.js will search in the following list of GLOBAL_FOLDERS:

    • $HOME/.node_modules
    • $HOME/.node_libraries
    • $PREFIX/lib/node

    Where $HOME is the user’s home directory, and $PREFIX is the Node.js configured node_prefix.

    That’s it for today’s lesson. We will continue more in Lesson 4.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Mohammad Shad Mirza
    • X (Twitter)
    • LinkedIn

    JavaScript lover working on React Native and committed to simplifying code for beginners. Apart from coding and blogging, I like spending my time sketching or writing with a cup of tea.

    Related Posts

    Mastering REST APIs: Essential Techniques for Programmers

    December 18, 2024

    Crafting Interactive User Interfaces Using JavaScript Techniques

    December 17, 2024

    Effective Strategies for Utilizing Frameworks in Web Development

    December 16, 2024

    Comments are closed.

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo
    Don't Miss
    Programming October 26, 2016

    22. Чат через long-polling, чтение POST. Pt.1.

    Всем привет! Цель этого занятия – научиться делать чат на Node.js. Для начала наш чат будет достаточно простой. Всего лишь каждый, кто заходит по этому url

    http://localhost:3000/

    автоматически попадает в комнату, в которой может получать сообщения от другого пользователя, находящегося в этой же самой комнате, в нашем случае переписка может вестись из разных браузеров. Мы будем делать его в начале без пользователей, базы данных, авторизации.

    Swarm Intelligence: Infusoria Slipper

    April 6, 2023

    Уроки React. Урок 6.

    September 20, 2016

    Mastering Lean Project Management: Essential Principles Guide

    December 4, 2024

    Categories

    • AI & Automation
    • Angular
    • ASP.NET
    • AWS
    • B2B Leads
    • Beginners
    • Blogs
    • Business Growth
    • Case Studies
    • Comics
    • Consultation
    • Content & Leadership
    • CSS
    • Development
    • Django
    • E-commerce & Retail
    • Entrepreneurs
    • Entrepreneurship
    • Events
    • Express.js
    • Facebook Ads
    • Finance & Fintech
    • Flask
    • Flutter
    • Franchising
    • Funnel Strategy
    • Git
    • GraphQL
    • Home Services Marketing
    • Influencer & Community
    • Interview
    • Java
    • Java Spring
    • JavaScript
    • Job
    • Laravel
    • Lead Generation
    • Legal & Compliance
    • LinkedIn
    • Machine Learning
    • Marketing Trends
    • Medical Marketing
    • MSP Lead Generation
    • MSP Marketing
    • NestJS
    • Next.js
    • Node.js
    • Node.js Lessons
    • Paid Advertising
    • PHP
    • Podcasts
    • POS Tutorial
    • Programming
    • Programming
    • Python
    • React
    • React Lessons
    • React Native
    • React Native Lessons
    • Recruitment
    • Remote Job
    • SaaS & Tech
    • SEO & Analytics
    • Soshace
    • Startups
    • Swarm Intelligence
    • Tips
    • Trends
    • Vue
    • Wiki
    • WordPress
    Top Posts

    Enhancing Software Development Efficiency: The Role of Version Control

    Development December 1, 2024

    Analyzing Emerging Trends in Health and Medical Marketing

    Medical Marketing August 27, 2025

    Create simple POS with React.js, Node.js, and MongoDB #13: Grouping, Sorting, Pagination

    JavaScript August 24, 2020

    Essential Strategies for Building a Robust Entrepreneurial Network

    Entrepreneurship November 27, 2024

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    About Us
    About Us

    Soshace Digital delivers comprehensive web design and development solutions tailored to your business objectives. Your website will be meticulously designed and developed by our team of seasoned professionals, who combine creative expertise with technical excellence to transform your vision into a high-impact, user-centric digital experience that elevates your brand and drives measurable results.

    7901 4th St N, Suite 28690
    Saint Petersburg, FL 33702-4305
    Phone: 1(877)SOSHACE

    Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
    Our Picks
    Recruitment

    Optimizing Recruitment: Best Practices for Employers and Candidates

    Interview

    How to Hire a Freelance Web Developer: Things to Look For and Avoid

    Recruitment

    Enhancing Employee Retention: The Critical Role of Recruiters

    Most Popular

    How to Upload Images and Videos to Cloudinary in Your Node.js Application: Step-by-Step Tutorial

    Node.js

    15 Common JavaScript Questions

    Interview

    Essential Recruitment Metrics: Measurement Strategies and Impact

    Recruitment
    © 2025 Soshace Digital.
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.