How to Build a Web Server with Node JS | Node.js Tutorials for Beginners

Поделиться
HTML-код
  • Опубликовано: 28 окт 2024

Комментарии • 95

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  3 года назад +13

    In this tutorial, we will learn how to build a web server with Node.js without using a framework like Express JS. Using only Node.js will help introduce some foundational knowledge about Node that will continue to help us as we work with Node.js and Express JS in the future. If you are just starting out with Node.js, I suggest starting at the beginning of the Node.js for Beginners playlist here: ruclips.net/p/PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw

  • @AdityaDey424
    @AdityaDey424 Год назад +11

    I don't know why I got to know about this channel a few days ago. You are a gem & all playlists are well structured. Thanks a lot sir 🙏

  • @jamesmassa1999
    @jamesmassa1999 3 года назад +12

    Dave this is an excellent series!! Watched each video as it comes out! Please keep producing these excellent videos they are so beneficial!!!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +5

      Thanks James! After this tutorial, the series adds in Express and eventually MongoDB to round out the MERN stack backend REST API construction. I appreciate your note! 💯

  • @yogeshkhatri4555
    @yogeshkhatri4555 Год назад +1

    This is it. I want this level of clarity even if it is among the most basic ones. HatsOff bro. keep going

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад +1

      Glad to hear that!

    • @yogeshkhatri4555
      @yogeshkhatri4555 Год назад

      @@DaveGrayTeachesCode Can u tell me like how can we optimize a server like we can using bundling in a client that can remove all reusable files.

  • @elvispontes4165
    @elvispontes4165 Год назад +2

    Excelent tutorial Dave!!! Thanks a lot for sharing!!!

  • @fares.abuali
    @fares.abuali 3 года назад +4

    Thanks Mr. Dave,
    I have learnt a lot from you and recommended your videos to my colleagues.

  • @leomacdon7858
    @leomacdon7858 Год назад +1

    I've made a wise decision to spend time on this RUclips channel. Thank you Dave.

  • @moiraleon8744
    @moiraleon8744 2 года назад +1

    Love all of these videos. Thank you so much!

  • @아서-i4m
    @아서-i4m 2 года назад +1

    Dave. You're amazing!! love your videos!!

  • @mostafahusany1747
    @mostafahusany1747 Год назад

    I watched this video several times and I just want to keep press like 1000 time and it's not enough for your efforts

  • @kakhabervk9405
    @kakhabervk9405 Год назад

    This is best example of node server I did watched!

  • @ahmad-murery
    @ahmad-murery 3 года назад +3

    I like to know how stuffs work and maybe this is why I like building things from scratch,
    I might use Map instead of the extension switch but I know this is just an intro to node server so refactoring is not beneficial,
    Great work as always my friend 🚀👍

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +2

      A great observation Ahmad! I also like building from scratch - such a great way to learn. Thanks for the note. We will be moving on to Express JS next!

  • @vikrambabariya5166
    @vikrambabariya5166 2 года назад +2

    learned so many things from this video 👍👍 thank you for this amazing series.

  • @BrainNotUsed
    @BrainNotUsed 3 года назад +1

    Superb content as always!

  • @alikisang827
    @alikisang827 2 года назад

    Dave is an excellent teacher☺️☺️👍

  • @Salma-qy3qb
    @Salma-qy3qb 4 месяца назад

    You're Awesome, Thank you so much

  • @vuejs1
    @vuejs1 Год назад

    This is pure gold😊

  • @MrSalFav
    @MrSalFav 2 года назад

    Wow!! speachless, This is really good. THANK YOU !

  • @TinyMaths
    @TinyMaths Год назад +1

    Not sure if anybody else had the same trouble as me; currently looking for an answer. Images won't render to the page. I've checked the switch statement for extension types using (for example with png images):
    switch(extension){
    case '.png':
    contentType = 'image/png'
    break;
    }
    but I logged extention (from inside the switch statement); which confirmed that the extension is png, and contentType from the serveFile function; but instead of contentType being given as 'image/png', it is being given as 'text/html' as if the variable isn't working properly. It works for .txt, .html, and .json extensions, but it looks like CSS and image extensions return contentType as 'text/html'. I even tried using 'PNG File' as the file type (as that's how they are named in Windows); but contentType won't change from 'text/html'.
    EDIT: came back to say problem solved. For some reason the file types were being missed so I created an if condition of 'if(extention && contentType !== 'text/html'){ filePath = path.join(__dirname, req.url). That worked for the CSS, but the images were not showing and, as per the condition for when files don't exist, the text/html was being used as contentType. I also noticed for my image named 'rubber duck.png', the req.url was being logged as 'rubber%20duck.png' and I wondered if that was the reason it was not recognized and maybe the path (or http) module putting '%20' in place of a space between image name words was causing the issue. I replaced the space with a hyphen and 'voila', the images showed.

  • @iconicscene3768
    @iconicscene3768 10 месяцев назад

    Hi Mr.Dave,
    I have a question concerning the parse and the stringify part of this lecture. Would it have been better if we serve the json data without parse in it and stringify it again as long the readFile() for .json extension do that already and the receiver could parse and consume the data correctly?
    by the way i can't thank you enough for all what you've done seen much content but you've a unique philosophy ( Tought you the right way of doing it ). Am sure your hard work will be remembered forever ☺.

  • @HOW-bt3et
    @HOW-bt3et 3 месяца назад

    This is a perfect Tutorial , Thanks man. And I have a question I hope I don't make you feel bad just asking How old are you ?

  • @abdulrahmanagboolaosho3582
    @abdulrahmanagboolaosho3582 Год назад +2

    why do you love indentation so much, I have even picked up the habit from you

  • @TravinskiyVladislav
    @TravinskiyVladislav Год назад

    Thank you, Dave

  • @bardhan.abhirup
    @bardhan.abhirup 2 года назад

    Such a great tutorial!

  • @chetanjain4616
    @chetanjain4616 3 года назад +2

    Hey man, love your videos as a suggestion can you make a video or explain what is Cumulative Layout Shift (CLS) ?

  • @IG7799-c4u
    @IG7799-c4u 3 дня назад

    The source code link seems to have the completed code for this lesson. Wouldn't it be better to have the starter code for those who want to follow along?

  • @saxa1165
    @saxa1165 Год назад

    Thanks! It helps a lot!!

  • @teologomedio
    @teologomedio 10 месяцев назад

    Just Amazing!!

  • @sonamohialdin3376
    @sonamohialdin3376 2 года назад

    Amazing tutorial

  • @tech5956
    @tech5956 2 года назад

    Great video 😍

  • @haiderjaafer8164
    @haiderjaafer8164 3 года назад +1

    Great work keep going forward… can I use this in the restful api

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +2

      Yes, keep going in the series and we add Express to build a RESTful API.

  • @anjaneyulub2529
    @anjaneyulub2529 Год назад

    Hi Dave can u mention which vs code theme and icons u use?

  • @thesrinathkamath
    @thesrinathkamath 3 года назад +1

    Second!
    Great one bro!

  • @haiderjaafer8164
    @haiderjaafer8164 3 года назад +1

    absolutely informative lesson but there is some lines of code did not understand ... keep going

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +2

      If there are lines that are confusing, I suggest console logging values to see what each one is doing. Doesn't hurt to play around with it for understanding. 💯

    • @haiderjaafer8164
      @haiderjaafer8164 3 года назад +1

      @@DaveGrayTeachesCode
      I already trying to do console log .. thanks 🙏

  • @thesrinathkamath
    @thesrinathkamath 3 года назад +1

    Can you deploy this on shared hosting (Not VPS, not cloud) via terminal?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +1

      It just needs a host that supports Node.js. For example, Heroku has their own CLI which would let you deploy from the terminal. You could also set up continuous deployment from GitHub to Heroku or another host if the host supports it.

    • @thesrinathkamath
      @thesrinathkamath 3 года назад +1

      @@DaveGrayTeachesCode No need of node support bro. If you can share me your email, I can send u the code and take a look and probably make a video of it.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +1

      I must be confused. I thought you were asking about this Node.js tutorial project as shown in the video. The host service definitely needs to have support for Node.js to host this project.

  • @immortalaigs4203
    @immortalaigs4203 2 года назад +1

    Where can i practise this kind properties Dave?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      I always recommend freeCodeCamp.org to my students. It offers many exercises to help you practice. There are both Javascript and Node JS sections there.

    • @immortalaigs4203
      @immortalaigs4203 2 года назад +1

      @@DaveGrayTeachesCode Thank youu so much Mr Dave !;

  • @TheNamesJT
    @TheNamesJT 3 года назад +2

    13:27 chain ternary hell

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 года назад +2

      I know I differ from some, but I like chained ternaries much better than large if statements. Feel free to use your preference. 😃

  • @francescotagliavento8081
    @francescotagliavento8081 3 года назад +1

    which extension do you have for icons?

  • @LemanGahramanova-kh8fb
    @LemanGahramanova-kh8fb 6 месяцев назад

    It's so good tutorial for me, but I have a question, for example in browser when i write localhost:3500/subdir -> it doesn't work but localhost:3500/subdir/works I found some solutions, but they don't work, how I can solve it? Is anyone knows?

  • @wedangstudio6354
    @wedangstudio6354 2 года назад

    thank you

  • @codinggyan1009
    @codinggyan1009 Год назад

    very nice this video

  • @thebocksters2756
    @thebocksters2756 6 месяцев назад

    1:39 why we extends EventEmitter and not use it independently

  • @mohammad._.abohasan
    @mohammad._.abohasan Год назад

    Thank you for this wonderful video

  • @a7medabdulshafi887
    @a7medabdulshafi887 2 года назад

    Awesome

  • @alirezahekmati7632
    @alirezahekmati7632 2 года назад

    🚀

  • @dafiraone
    @dafiraone 2 года назад

    How to show the length of the block of code inside curly braces? like on 10:33

  • @whathuh6965
    @whathuh6965 14 дней назад

    Can I use this in 2024?

  • @elinordeniz
    @elinordeniz Год назад

  • @wildcat718
    @wildcat718 2 года назад

    why on 27:36, it is just text, not JSON? what's difference between 27:36 and 30:26?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      At 27:36, we have not configured the server to handle sending a JSON response yet so it is defaulting to the text response that is configured. It looks like JSON, but it is a text response. By the time we reach 30:26, we have configured our server to send a response type of application/json.

    • @brandonjoaocastillo7490
      @brandonjoaocastillo7490 2 года назад

      if you try in Firefox it would be more obvious, the Browser knows when the data is plain text or json, you should try in Firefox, it makes things more clear

  • @shanglee643
    @shanglee643 3 года назад +1

    first.

  • @nazmulalam4874
    @nazmulalam4874 2 года назад

    I am noob this is hard for me

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Don't give up, but as a noob, have you learned Javascript first? You should learn Javascript before starting Node.js.

  • @shineLouisShine
    @shineLouisShine 2 года назад

    Thank you very much.
    37:20 -
    Why in my code, despite writing exactly the same as you did
    (`${err.name}: ${err.massage})
    And despite of deleting the exact same letter as you did for the purpose of occuring this error,
    Yet, the error in the my errLog.txt file appears as: " TypeError: undefined. "
    Instead of displaying the error's name and message..?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      There must be a difference even though you suggest it is exactly like mine. For example, in your comment you said: err.massage ...but it should be err.message

    • @shineLouisShine
      @shineLouisShine 2 года назад

      @@DaveGrayTeachesCode You are sharp :)) Thank you!
      An automatic typing error could be a major assistance.
      Sometimes I'm surprised of how advanced those softwares are,
      While being kind of primitive regarding typing errors handling.

  • @1conscience0dimension
    @1conscience0dimension 6 месяцев назад

    00:17:40 no need for the last line (if (!extension && req.url.slice(-1) !== '/') filePath += '.html';)
    you just needed to add one more level of craziness to the ternary
    contentType === 'text/html'
    ? extension === html ? path.join(__dirname, 'views', req.url) : path.join(__dirname, 'views', req.url)+".html"
    : path.join(__dirname, req.url);
    😂