Original link: Http://blog.csdn.net/u010053344/article/details/50545304Mac installation Nodejs
These days because of demand and temporary use to Nodejs, before installing several times, but every time still can't help Baidu under, so this mark under the Mac under the Nodejs installation and testing, to leave a mark for themselves, improve the efficiency of the next.
Step 1:
- Visit Nodejs website, click on the Blue Marquee area stable, and download https://nodejs.org/en/
Step 2:
- Double-click the file you just downloaded and follow the steps to install it by default.
Step 3:
- When the installation is complete, open the terminal, enter
Npm-v
Node-v
Two commands, such as version information, indicate that the installation was successful.
Step 4:
- Create a new JS file, Nodejstest.js, enter the following code, and save
var HTTP = require ( "http"); Http.createserver (function200, { "Content-type": "Text/plain"}); Response.Write ( "Welcome to Nodejs"); Response.End ();}). Listen (8000, "127.0.0.1"); Console.log ( "creat server on Http://127.0.0.1:8000/");
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- Open terminal into nodejstest.js directory, enter node Nodejstest
- Open the browser, click or enter Http://127.0.0.1:8000/, if unable to open, you can remove the. Listen (8000, "127.0.0.1") in the IP listener changed to. Listen (8000), then tap or enter http:// Localhost:8000/
MAC installation Nodejs