Logo
HTMLCSSJavaScriptReactjsnewContactUpdates

Get started today

HTMLCSSJavaScriptReactjsnewContactUpdates

Tools

Resume BuilderQR GeneratorVS Code Editor

Connect

GitHubWhatsApp Channel
reactjs installation and setup
React fiber

Introduction to Node.js and npm

By Saket Bhatnagar•April 17, 2025•Beginner to Intermediate

Table of Contents

  1. Nodejs
  2. Npm
  3. Npx

Nodejs

  1. 1Node.js is a runtime environment that allows JavaScript to run outside the browser.
  2. 2It is commonly used to build backend servers, tools, and full-stack applications.
  3. 3When you install Node.js, npm (Node Package Manager) gets installed automatically.
  4. 4Node.js, npm, and npx together form the foundation for modern JavaScript development.
  5. 5Download Node.js from here

Npm

  1. 1npm is used to install and manage packages (libraries, tools, frameworks) for your project.
  2. 2A package is a reusable set of code shared by developers — like React, Express, Lodash, etc.
  3. 3npm downloads packages from the npm registry, which is a public online database.
  4. 4You search for packages on npmjs.com
  5. 5Every project that uses npm has a file called package.json.
  6. 6package.json lists all the dependencies (packages) your project needs.
  7. 7We have two files in our project: package.json and package-lock.json.
  8. 8package-lock.json is used to keep track of the exact versions of installed packages.
  9. 9When you run npm install, npm reads package.json and installs all listed dependencies.
  10. 10The packages are stored locally in a folder named node_modules, where all the installed code lives and it is created automatically when you run npm install.
  11. 11This allows each project to have its own set of packages without affecting other projects.
  12. 12 You can install a package using npm install package-name.
  13. 13You can install a specific version using: npm install package-name@version.
  14. 14

    Example: Install React version 18.2.0

    1npm install react@18.2.0
  15. 15npm uses semantic versioning — like 1.2.3 (major.minor.patch) — to manage package versions.
  16. 16Global installation is done with: npm install -g package-name.
  17. 17npm keeps a local cache of downloaded packages to speed up future installs.
  18. 18

    You can clear cache using:

    1npm cache clean --force
    💡

    Note

    This will remove all the cached packages and clear the cache.

Npx

  1. 1npx is a tool that comes with npm — it runs a package directly without installing it globally.
  2. 2

    Example: Create a new React project

    1npx create-react-app my-app
  3. 3npx avoids polluting your global system with packages you only need temporarily.
  4. 4

    Example: Check globally installed packages

    1npm list -g --depth=0
  5. 5npm installs the package into your project, while npx runs it directly without saving it.

Share this article

Last updated: April 17, 2025

Join Our Community

Login to Join

© 2025 Saket Bhatnagar. All rights reserved.

    ☕