1. Open a Web Browser Like Chrome, Edge or another
2. Download Node.js on the Web browser you use or click the following link NodeJS (currently recommended version v20.16.0 (LTS))
3. Download GitBash for the terminal on the website you use or click the following GitBash link
4. Open the GitBash that you downloaded
5. Check your node version (current recommended version is v20.16.0 (LTS)) by typing node -v
6. Create a directory for your project by typing mkdir your-project-name
7. Enter the directory you created by typing cd your-project-name
8. Create a file main.js (file name as needed) using echo accompanied by console.log before the file name
9. Run the file you have created by typing node main.js
10. See the Results
The results will come out like this
11. If editing is required, you can type nodepad main.js
Note:
node -v = view node.js version. minimum version 20
npm -v = to see the npm (package managing) version. minimum version 10
node = runs js file
ls = to view the contents of the folder
ls -a = to see all folder contents including hidden ones
DIR = to view the contents of the folder in Windows
mkdir = creates folder
cd = to go to folder
cd .. = to exit folder
touch = to create file (os)
echo 'console.log("hello students")' > main.js (create file)
rm = to delete files (MAC)
del = to delete files (Windows)
Nano / Edit file contents (Only on MAC OS and Linux)
nano = edit file
ctrl + o = save file (enter)
ctrl + x = exit edit file
The above is the detailed content of How To Use Node JS By Displaying (\'Hello World\'). For more information, please follow other related articles on the PHP Chinese website!