Windows System node. JS (Install-Start-Test)

Source: Internet
Author: User

Baidu enters the node. JS official website (https://nodejs.org/), download Windows platform NODEJS Environment installation package, find downloads click, find Windows Installer if 64-bit PC can choose 64-bit version. Click Download.
  
  
  
Install Windows version Nodejs, click on the downloaded file to install and then click Next, then select agree to install the protocol, then click Next, then you can customize the installation directory by default C:\Program files\nodejs\, then click Next, Install all the components by default, then click Next, then tap Install to wait, then click Finish to install.
  
  
  
  
Installation related environment
Entering the node. js Command Prompt Commands window
  
Type the command: CD C:\Program Files\nodejs
  
Start installing the relevant environment now
Type command: NPM Express enter wait for installation Express
Type the command: NPM Jade return waiting to install Jade
Type command: NPM mysql enter wait for MySQL to install
Note: By default, the above components are installed under the C:\Program Files\nodejs\node_modules folder, which is also the auto-find path for NODEJS related components.
 
NPM Installation
  
The new version of Nodejs integrates NPM, and you can use the cmd command line to enter "Npm-v" to test for successful installation. For example, a version prompt indicates that the installation was successful.
  
Installation related environment
NPM Install Express-g
NPM Install Jade-g
NPM Install Mysql-g
  
Installing Coffeescript
NPM Install Coffee-script-g
  
Additional notes:
All commands are globally installed by-G, so that the installation packages are installed under the current user and can be accessed in all other areas of the disk, in comparison. Otherwise, it is installed in the current directory and can only be used in the current directory.
  
Installing the Express issue
After installing the NODEJS installation package, after installing Express via NPM, the express prompt "Express" is not an internal or external command, because of the version issue, the current version is 4.0.0, changed to 3.5.0 to run.
$ NPM install-g [email protected]
  
Create a project
Type: Express MyApp (MyApp project name can be customized)
Copy the Node_modules under MyApp
Set up the environment to complete this, the following to do a demo test!
Create a new helloworld.js under MyApp
  
Start node. js
Two different ways:
1. Click the application icon from the Start menu to start
  
2. Enter node directly from the command line into the node environment, enter Console.log ("Hello world!") Test Console node console output.
  
  
Test node
Write test file Test.js Here we'll put it on the D-disk Demo:
  
  

     var http = require ("http"); Http.createserver (function(request, Response) {Response.writehead ($, {"Content-type": "   Text/plain "});   Response.Write ("Test Nodjs");   Response.End ();   }). Listen (8899); Console.log ("Nodejs start listen 8899 port!");        

Note: Set the browser port information here we use 8899.
  
Start testing
Open the node. js command line, switch to the node. JS Test Code directory, and enter the node testnode.js command on the command line.
  
The Firewall Warning window appears (due to firewall settings), do not panic, direct click the Allow Access button to run.
  
Then open the browser input browse Address: http://127.0.0.1:8899 or http://localhost:8899 to run the Test.js file.
The results are as follows:
  
  
Everything is running normally, today's primary exploration of node. JS is here, in the future article will further record my learning process, thank you.

Windows System node. JS (Install-Start-Test)

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.