Skip to main content

Posts

Showing posts with the label npm

How to Set Up and Run Your First Node.js Project

How to Set Up and Run Your First Node.js Project New to Node.js? This guide walks you through setting up your first Node.js project from scratch—whether you’re building APIs, CLI tools, or learning backend development. 1. What is Node.js? Node.js is a runtime environment that allows you to run JavaScript on the server side. It’s fast, event-driven, and perfect for building scalable web apps and services. 2. Install Node.js Download and install Node.js from the official website: https://nodejs.org Once installed, verify it in your terminal: node -v npm -v 3. Create Your Project Folder Open your terminal and create a new directory for your project: mkdir my-first-node cd my-first-node 4. Initialize a New Node.js Project Use npm (Node Package Manager) to create a package.json file: npm init -y This will generate a basic configuration file to manage your project dependencies. 5. Create Your First Script ...

How to Build and Publish a Custom Node.js Utility Package

Build a Custom Node.js Utility Package – Step-by-Step Guide 🚀 View GitHub Repo: node-custom-package-guide 💡 Want to reuse common string operations like capitalize() or slugify() across projects? Learn how to create and publish your own Node.js utility package! 📁 Project Structure custom-package/ ├── index.js ├── package.json ├── README.md └── utils/ ├── capitalize.js ├── camelCase.js ├── slugify.js └── greeting.js ✅ Initialize the Package npm init -y This creates a package.json with default values. 🧩 Write Utility Functions utils/capitalize.js function capitalize(str) { return str.charAt(0).toUpperCase() + str.slice(1); } module.exports = capitalize; utils/camelCase.js function camelCase(str) { return str .replace(/\s(.)/g, (match, group1) => group1.toUpperCase()) .replace(/\s/g, '') .replace(/^(.)/, (match, group1) => group1.toLowerCase()); } module.exports ...