Node Getting Started Tutorial (4) Chapter Three: the First Nodejs program

Source: Internet
Author: User

First Nodejs Program

This tutorial is only suitable for you already have a certain JS programming foundation or is the back-end language development Foundation.
If you are a 0 basis, it is recommended that you first learn about the front end of the old horse free video tutorial

First step: Create a project folder

First create the Demos folder. Then create the file under this folder 01_hello.js

# 以下是linux/mac下使用终端用命令行创建文件,windows下请直接用资源管理可视化鼠标操作$ mkdir demos && cd demos# 创建 01_hello.js文件$ touch 01_hello.js
Step two: Write the first program file for Nodejs

Then use the editor (recommended: Vscode or sublime) to open the file: 01_hello.js , and add the following code:

// 以下是常规的JS语法,如果您还不熟悉js,请您移步老马的// 免费在线js全套视频教程: https://qtxh.ke.qq.com// console是控制台的意思,node把浏览器端的控制台做了迁移整合,可以直接使用。log是往控制台打印文字的方法。console.log(‘Hi, aicoder.com! Hello, world!‘);

Save the file and use node to execute the JS file.

Step three: Compile and run the JS file

Open the system's command-line tool (Mac|linux is terminal, Windows is cmd or PowerShell), and use the CD command to enter the Demos folder. Run the command to compile and execute the JS file:

# 进入demos目录$ cd demos$ node ./01_hello.jsHi, aicoder.com! Hello, world!

At this point, your first node program is already running successfully, i.e. your NODEJS environment is no longer a problem.

Old horse free Video tutorial

Back to Tutorial list home

GitHub Address: Https://github.com/malun666/aicoder_node

Node Getting Started Tutorial (4) Chapter Three: the First Nodejs program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.