- Installing Node.js
Open Browser: Open Google Chrome or Microsoft Edge.
Download Node.js:
Visit the Node.js website.
Select the latest version that suits your operating system, for example Windows 64-bit.
Click on the latest version (for example, version 2.46.0) to download the installer.
Install Node.js:
Once the download is complete, open the installer file.
Follow the installation steps displayed on the screen.
Once finished, Node.js and npm (Node Package Manager) will be installed on your system.
- Checking Node.js Installation
Open Command Prompt (CMD):
Press Win + R, type cmd, and press Enter.
Check Node.js version:
Type node -v and press Enter. This will display the installed version of Node.js.
Check npm version:
Type npm -v and press Enter. This will show the version of npm installed.
- Create and Run the "Hello World" Program
Create New Folder:
In Command Prompt, type mkdir HelloWorld and press Enter. This will create a new folder called "HelloWorld".
Go to Folder:
Type cd HelloWorld and press Enter to enter the folder.
Create a New JavaScript File:
Type echo console.log('Hello World!') > app.js and press Enter. This will create a new file called app.js with code that displays "Hello World!" inside it.
Run Program:
Type node app.js and press Enter. You will see the text "Hello World!" appears on the screen.
- Done!
You have successfully run the "Hello World" program using Node.js. Next, you can start experimenting further with Node.js to develop more complex applications.
The above is the detailed content of Tutorial on how to use node.js to display \'Hello World\'. For more information, please follow other related articles on the PHP Chinese website!