Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript code outside of a browser, enabling server-side scripting and building scalable network applications.
npm init
npm init
is a command used to create a new package.json
file for a Node.js project. The package.json
file contains metadata about the project, such as its name, version, dependencies, and scripts. Running npm init
helps set up and manage your Node.js project's configuration.
npm init -y
is a command used to quickly create a new package.json
file for a Node.js project with default values. This saves time by skipping the interactive prompts. The package.json
file contains metadata about the project, such as its name, version, dependencies, and scripts.
const express = require('express'); const app = express(); const PORT = process.env.PORT || 3000; app.get('/', (req, res) => { res.send('Hello, World!'); }); app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); });- mongoose: npm install mongoose