Skip to main content

Command Palette

Search for a command to run...

L1. INTRODUCTION(Node.js & NPM Basics)

Published
โ€ข1 min readโ€ขView as Markdown

What is Node.js?

  • JavaScript runtime to run JS outside the browser.

  • Ideal for building server-side applications (APIs, etc.).

  • Uses NPM (Node Package Manager) for managing packages.

Problem & Solution

Problem:

Manually typing and running each line of code is inefficient.

Solution:

  • Packages: Pre-written code to simplify tasks.

  • Download from npmjs.com using NPM commands.

NPM Basics

Installing a Package Globally

npm i -g nodemon
  • -g flag installs nodemon globally.

  • Avoids restarting server manually.

Running Nodemon

nodemon --version  
nodemon index.js
  • Runs index.js without needing manual restarts.

Setting Up a Node.js Project

Initializing a Project

npm init
  • Creates a package.json file (contains project metadata).

  • Requires inputs like:

    • Package name

    • Version

    • Entry point (default: index.js)

More from this blog

N

Nodejs

12 posts