If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
तो जैसा कि आप पढ़ चुके हैं कि ExpressJS एक Node.js web application framework है जो हमें ready तो use functionality और tools provide कराता है , जिनकी help से हम development को efficient और fast बना सकते हैं। ExpressJS को आप simply NPM (Node Package Manager) के though easily install कर सकते हैं।
जिस तरह से PHP के लिए composer होता है बैसे ही NodeJs के लिए NPM. यह एक package manager है , इसकी help से आप external libraries install कर सकते हैं।
आपने NodeJS को पहले से install कर लिया है , अगर नहीं तो Install कर ले , इसके लिए आप NodeJS Installation Topic देख सकते हैं।
तो expressJS install करने से पहले हम एक test name का project initialize करते हैं , जिसके लिए हमें npm init command run करनी पड़ेगी।
C:\Users\HP\Desktop>mkdir test C:\Users\HP\Desktop>cd test C:\Users\HP\Desktop\test>npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help init` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg>` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. package name: (test) nodejs version: (1.0.0) description: for learning purpose test command: git repository: keywords: author: license: (ISC) About to write to C:\Users\HP\Desktop\test\package.json: { "name": "nodejs", "version": "1.0.0", "author": "", "license": "ISC" } Is this OK? (yes) yes C:\Users\HP\Desktop\test>
npm init command run करते ही आपसे package name , version , description , author etc info enter करने के लिए कहेगा , हालाँकि आप इन्हे skip करके भी आगे बढ़ सकते हैं।
npm install express
That's it, यह command run करते ही ExpressJS install हो हो जायगा , test करने के लिए एक index.js file बनाएं और , नीच दिया गया code रख दें।
// import express module.
const express = require('express');
const app = express();
const port = 8000;
// define route
app.get('/', function (req, res) {
res.send('Welcome to learnhindituts.com');
});
//listen server.
app.listen(port, function () {
console.log(`Server is running at http://localhost:${port}`);
});
इसके बाद node index.js command run करके server restart करें और http://localhost:8000 browser में hit करें।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook