官术网_书友最值得收藏!

  • Learning Node.js Development
  • Andrew Mead
  • 327字
  • 2021-06-30 18:56:44

Creating the Node application

The first step will be to create a folder. Every project we create will go live inside of its own folder. I'll open up the Finder on macOS and navigate to my desktop. What I'd like you to do is open up the desktop on your OS, whether you're on Linux, Windows, or macOS, and create a brand new folder called hello-world.

I don't recommend using spaces in your project file or folder names, as it only makes it more confusing to navigate inside of Terminal. Now, we have this hello-world folder and we can open it up inside of our editor.

Now I'll use command + O (Ctrl + O for Windows users) to open up, and I'll navigate to the desktop and double-click my hello-world folder, as shown here:

On the left I have my files, which are none. So, let's create a new one. I'll make a new file in the root of the project, and we'll call this one app.js, as shown here:

This will be the only file we have inside our Node application, and in this file we can write some code that will get executed when we start the app.

In the future, we'll be doing crazy stuff like initializing databases and starting web servers, but for now we'll simply use console.log, which means we're accessing the log property on the console object. It's a function, so we can call it with parentheses, and we'll pass in one argument as string, Hello world!. I'll toss a semicolon on the end and save the file, as shown in the following code:

console.log('Hello world!');

This will be the first app we run.

Now, remember, there is a basic JavaScript requirement for this course, so nothing here should look too foreign to you. I'll be covering everything new and fresh inside of this course, but the basics, creating variables, calling functions, those should be something you're already familiar with.
主站蜘蛛池模板: 内乡县| 丹巴县| 甘南县| 故城县| 剑川县| 咸宁市| 天气| 望谟县| 宣城市| 通许县| 乌鲁木齐市| 金昌市| 资兴市| 海原县| 无为县| 博湖县| 五常市| 清河县| 肥城市| 开江县| 比如县| 云林县| 裕民县| 元氏县| 耿马| 镇赉县| 鄂尔多斯市| 东兰县| 南充市| 蕉岭县| 改则县| 临沧市| 高雄县| 渑池县| 固原市| 涟源市| 公主岭市| 贡山| 基隆市| 婺源县| 富川|