Installing Node.js and Running Your First Node.js Application

Installing Node.js and Running Your First Node.js Application

Daily short news for you
  • Here! A question that I've been wondering about for ages, and until yesterday, everything was finally clarified.

    Normally, people use height: 100vh to set the height equal to the viewport of the screen. On computers, there's no issue, and even simulating the size of a smartphone works fine. But when opened on a phone, height: 100vh always exceeds the viewport. Huh!? What's going on???

    The explanation for this is that mobile devices have a different way of calculating the viewport compared to computers. It is often interfered with or affected by the address bar and navigation bar of the platform you are using. Therefore, if you want 100vh on mobile to truly equal the viewport, you need to take an additional step to reset the viewport.

    It's easy, first, you need to create a CSS variable --vh right in the script tag at the top of the page.

    function updateViewportHeight() { const viewportHeight = globalThis.innerHeight; document.documentElement.style.setProperty('--vh', `${viewportHeight * 0.01}px`); } updateViewportHeight(); window.addEventListener('resize', updateViewportHeight);

    Then instead of using height: 100vh, change it to height: calc(var(--vh, 1vh) * 100). And that's it.

    » Read more
  • Nowadays, how much memory will 1 million (1M) concurrent tasks consume? That is the question posed by hez2010, and he decided to find the answer by experimenting with a simple program in various programming languages: How Much Memory Do You Need in 2024 to Run 1 Million Concurrent Tasks?

    To summarize, Rust remains unbeatable, but the second position surprised me 😳

    » Read more
  • Is something coming? 😱🥶

    » Read more

Node.js is an open-source software that is available for free download on the Node.js download page.

Installation

  • For Windows users, click on the Windows Installer
  • For Mac users, click on the macOS Installer
  • For Linux users, you can install it using a package manager

For example, to install Node.js LTS (v12.x) on Ubuntu, you can run the following commands:

curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

Your First Hello World Program

Running a JavaScript application with Node.js is quite simple. Let's create a file called index.js with the following content:

console.log('Hello World');

Save the file and run the following command in the command line:

node index.js

Output:

Hello World
Premium
Hello

5 profound lessons

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.
Author

Hello, my name is Hoai - a developer who tells stories through writing ✍️ and creating products 🚀. With many years of programming experience, I have contributed to various products that bring value to users at my workplace as well as to myself. My hobbies include reading, writing, and researching... I created this blog with the mission of delivering quality articles to the readers of 2coffee.dev.Follow me through these channels LinkedIn, Facebook, Instagram, Telegram.

Did you find this article helpful?
NoYes

Comments (1)

Leave a comment...
Avatar
Xuân Hoài Tống1 year ago
Ôi bài viết đã từ hơn 3 năm trước
Reply
Avatar
Xuân Hoài Tống1 year ago
Bài viết thật sơ sài 😅