Varanasi-Software-Junction / Node-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Steps to Run a Hello World Node.js Program:

  1. Install Node.js:

    • If you haven't already installed Node.js, visit the official Node.js website (https://nodejs.org) and download the appropriate installer for your operating system.
    • Follow the installation instructions provided on the website to install Node.js on your machine.
  2. Create a JavaScript File:

    • Open a text editor (such as Visual Studio Code, Sublime Text, or Notepad) on your computer.
    • Create a new file with a .js extension. You can name it hello.js or any other name you prefer.
  3. Write the Hello World Code:

    • Inside the .js file, write the following code:
      console.log("Hello, World!");
    • This code will simply print "Hello, World!" to the console when executed.
  4. Save the File:

    • Save the .js file in a directory of your choice on your computer. Remember the location where you saved it, as you'll need to navigate to this directory in the terminal.
  5. Open Terminal (or Command Prompt):

    • Open a terminal or command prompt on your computer. You can usually find it by searching for "Terminal" (on macOS and Linux) or "Command Prompt" (on Windows) in your operating system's search bar.
  6. Navigate to the Directory:

    • Use the cd command in the terminal to navigate to the directory where you saved the hello.js file.
      cd path/to/your/directory
      
    • Replace path/to/your/directory with the actual path to the directory where you saved the hello.js file.
  7. Run the Node.js Program:

    • Once you're in the correct directory, type the following command in the terminal and press Enter:
      node hello.js
      
    • This command tells Node.js to execute the hello.js file.
  8. See the Output:

    • After executing the command, you should see the output "Hello, World!" printed in the terminal.

About

License:MIT License


Languages

Language:HTML 74.9%Language:EJS 17.5%Language:JavaScript 7.6%