Developer Cheat Sheet: NPM, Angular & .NET Commands

What is node_modules?

node_modules is the folder where all project dependencies (packages/libraries) are installed.

Examples:

  • Angular packages
  • React packages
  • Ionic packages
  • Express packages

Sometimes dependencies become corrupted or outdated, so we delete and reinstall them.


What is npm?

npm (Node Package Manager) is used to install, update, and manage project packages.

Check npm version:

npm -v

Check Node.js version:

node -v

Clean Installation

Linux / macOS

Remove Existing Dependencies

rm -rf node_modules

Deletes all installed packages.

Install Packages

npm install

Reads package.json and installs all required dependencies.

Build Project

npm run build

Creates an optimized production build.


Windows

Remove Existing Dependencies

rmdir /s /q node_modules

Deletes all installed packages.

Install Packages

npm install

Installs all dependencies listed in package.json.

Build Project

npm run build

Creates the production build.


Useful NPM Commands

Install a Package

npm install package-name

Example:

npm install bootstrap

Install as Development Dependency

npm install package-name --save-dev

Example:

npm install typescript --save-dev

Update Packages

npm update

View Installed Packages

npm list

Uninstall a Package

npm uninstall package-name

Git Fundamentals

Check Git Version

git --version

Initialize Repository

git init

Creates a new Git repository.

Check Status

git status

Shows modified, staged, and untracked files.

Add Files

git add .

Stages all files for commit.

Commit Changes

git commit -m "Your message"

Creates a snapshot of changes.

View Commit History

git log

Clone Repository

git clone <repository-url>

Downloads a project from GitHub.

Pull Latest Changes

git pull

Downloads and merges latest changes.

Push Changes

git push

Uploads local changes to GitHub.


Branch Commands

View Branches

git branch

Create Branch

git branch feature-name

Switch Branch

git checkout feature-name

Create and Switch

git checkout -b feature-name

Merge Branch

git merge feature-name

Angular Commands

Create Project

ng new project-name

Run Application

ng serve

Run on Custom Port

ng serve --port 4201

Generate Component

ng generate component component-name

Generate Service

ng generate service service-name

Build Application

ng build

Production Build

ng build --configuration production

Ionic Commands

Install Ionic CLI

npm install -g @ionic/cli

Create Project

ionic start project-name

Run Application

ionic serve

Build Project

ionic build

Add Android Platform

npm install @capacitor/android
npx cap add android

Sync Android

npx cap sync android

Open Android Studio

npx cap open android

.NET Commands

Check SDK Version

dotnet --version

Create Web API

dotnet new webapi -n ProjectName

Restore Packages

dotnet restore

Build Project

dotnet build

Run Project

dotnet run

Publish Project

dotnet publish -c Release

Common Developer Jargons

Term Meaning
Repository (Repo) Project stored in Git
Commit Snapshot of changes
Branch Separate line of development
Merge Combine code from branches
Clone Download repository
Pull Get latest code
Push Upload code
Build Convert source code into deployable output
Dependency External package/library
Package Reusable code installed via npm
API Interface for communication between applications
Backend Server-side code
Frontend User interface
Deployment Publishing application to server
Production Live environment used by end users
Development Environment used during coding
Bug Software defect
Hotfix Urgent bug fix
Refactoring Improving code without changing behavior

First Steps After Cloning Any Project

git clone <repository-url>
cd project-folder
rm -rf node_modules # Linux
# OR
rmdir /s /q node_modules # Windows
npm install
npm run build
npm start

These commands solve most setup issues and ensure all dependencies are installed correctly.


No comments:

Post a Comment