Home  >  Article  >  Web Front-end  >  Installation and testing of node.js environment on mac

Installation and testing of node.js environment on mac

不言
不言Original
2018-03-31 15:01:311382browse


This article mainly introduces the installation and testing of the node.js environment on mac in detail. It has certain reference value. Interested friends can refer to it


If everyone who has done a web server before knows that nginx+lua and the now popular Node.js can both do web For servers, the former is more troublesome than the latter in terms of program writing and configuration, but they are almost the same. I suggest that if you don’t know about Lua scripting language, you can learn more about this scripting language. It is known as the best scripting language of all It is the scripting language with the highest execution efficiency. The bottom layer is based on C language, which is very easy to use and cross-platform!

Now I will configure the node.js environment for you.

Configuration of mac node.js environment

First step:Open the terminal and enter the following command to install Homebrew

ruby -e “$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install);

Step 2:Install node, enter the following command in the terminal

##

brew install node

##Step 3 Check whether the node installation is successful

node -v

##The node is successfully installed after the above three steps

Three program tests

Step one:Create a new file test.js

Step 2:Use the terminal to find the directory where it is located and run


The third step:Access through the browser and return the data in json format

Fourth Step:The front end can parse the data by calling this interface, and display the data on the current page.

End of three

Isn’t it very simple? If you have done web service interface development before, this should be familiar, and it is even very simple.

Related recommendations:

node .js blog project development experience sharing

Detailed explanation of Node.js module system examples

The above is the detailed content of Installation and testing of node.js environment on mac. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn