Learn JavaScript
Lesson 1 - Introduction To JavaScript
Lesson 2 - Basic JavaScript Syntax
Lesson 3 - Control Flow
Lesson 4 - Functions
Lesson 5 - Basic Data Structures
Lesson 6 - Basic String Operations
Lesson 7 - Basic Array Operations
Lesson 8 - Exception Handling
Lesson 10 - User Input
To manage Node.js packages, we utilize npm
or yarn
. While npm
is the default package manager, yarn
serves the same purpose.
To install packages, we first initialize the project.
Start by setting up the project:
npm init
This action creates a package.json
file, containing project metadata.
package.json
{ "name": "my-project", "version": "1.0.0", "description": "A simple project", "main": "index.js", "scripts": { "start": "node index.js" }, "dependencies": { "express": "^4.17.1" }, "devDependencies": { "eslint": "^7.32.0" }, "author": "Your Name", "license": "MIT" }
To add a package, execute:
npm install express
This installs express
and includes it in node_modules
.
To remove a package, use:
npm uninstall express
After installation, import the package:
const express = require('express');
Now, express
is ready for use in your project.
const express = require('express'); const app = express();
Some packages, like readline
, are included in Node.js by default, requiring no separate installation.