![]() ![]() Open a new tab in postman or any web browser and in the address bar, type and hit the Enter button. In your terminal (should be in the project directory), type node index.js and hit the Enter button. So we have this: const http = require('http') īasically, that is all you need do to create a server. Now this could be any free port, but we will be using port 3000 which is the conventional port. In the file, require the HTTP module like so: const http = require('http') Ĭall the createServer() method on it and assign it to a constant like this: const server = http.createServer() Ĭall the listen() method on the server constant like this: server.listen() The package.json file is just a file with all the details of your project. When completed, you should have a package.json file seated in your project directory. ![]() I named my project directory server-tutorial, but you can name yours as you please. Open a terminal and type the following to create a directory and open it: Let's start by creating a project directory. How to Create a Node Server without Expressįor the rest of this tutorial, I will be using VS code as my editor. The version may be different but that's OK. Your output should be similar to the image below: Terminal showing the versions of node and npm Type in each of the following commands and hit Enter.Go to your terminal/command prompt (run as administrator if possible).exe file (it follows the normal installation process). When the download is complete, install Node using the downloaded. Click on the recommended download button. ![]() If you haven't yet done so, you'll need to install Node and npm on your machine. I assume that you already understand the basics of Node.js, express and nodemon so we will just go straight to the practical parts. After that, we will see how to upload images to Cloudinary from the app we have created. We will begin without express and then strengthen the server using express. In this tutorial, we will learn how to create a server. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |