-
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.
-
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 ithello.js
or any other name you prefer.
-
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.
- Inside the
-
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.
- Save the
-
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.
-
Navigate to the Directory:
- Use the
cd
command in the terminal to navigate to the directory where you saved thehello.js
file.cd path/to/your/directory
- Replace
path/to/your/directory
with the actual path to the directory where you saved thehello.js
file.
- Use the
-
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.
- Once you're in the correct directory, type the following command in the terminal and press Enter:
-
See the Output:
- After executing the command, you should see the output
"Hello, World!"
printed in the terminal.
- After executing the command, you should see the output
-
-
Notifications
You must be signed in to change notification settings - Fork 1
License
Varanasi-Software-Junction/Node-js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published