What we mean by UI/UX
UI/UX |
2025-02-21 08:50:19
Setting up Node.js involves installing Node.js itself, configuring your development environment, and ensuring you have the necessary tools to start coding.
node -v # Check Node.js version
npm -v # Check npm (Node Package Manager) version
A good code editor makes development easier. Some popular choices:
If using VS Code, install the "Node.js Extension Pack" for a better experience.
mkdir my-node-app
cd my-node-app
npm init -y
This creates a package.json
file that stores project information and dependencies.Install packages using npm
(Node Package Manager). Example:
npm install express # Installs Express.js for building web applications
List installed packages:
npm list
app.js
and add:
console.log("Hello, Node.js!");
node app.js
Create a simple HTTP server using Node.js:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello, Node.js Server!');
});
server.listen(3000, () => {
console.log('Server running at http://localhost:3000');
});
Run the server:
node app.js
Open your browser and visit http://localhost:3000.
Instead of restarting the server manually after every change, install nodemon:
npm install -g nodemon
Run your app with:
nodemon app.js