NODEJS Environment Construction

Source: Internet
Author: User

First step: Download the installation file

: Official website http://www.nodejs.org/download/

Step Two: Install Nodejs

after the download is complete, double-click "node-v4.2.1-x64.msi", the installation process is basically directly "NEXT" is ok (window's installation MSI file will add the path system variable directly in the process, the variable value is your installation path )

After the installation is complete in cmd(win+r then enter cmd into) console input: node-v, the console will print out: v4.2.1, the version prompt indicates that the installation was successful.

Step Three: NMP installation

    • Since NPM has been integrated with the new version of Nodejs, NPM has been installed as well. You can also use the cmd command line to enter "Npm-v"

To test whether the installation was successful. For example, a version prompt indicates that the installation was successful.

    • The regular Nodejs has been completed so far, so you can enter node in "CMD"

mode, enter your Nodejs first sentence: "Hello World"-Enter: Console.log (' Hello World ').

    • NPM was managed as a Nodejs module, and I had to go a long way since I didn't have a systematic view of the data, which led to the installation of the configuration module.

Detours, so it is now necessary to list the records below.

    • We will first configure the path of the global module of NPM and the path of the cache, for example, I would like to place the above two folders in the Nodejs

's home directory, the "Node_global" and "Node_cache" two folders are created under Nodejs.

    • as     

    • Start cmd (win+r) type as follows:

NPM configSetprefix "Xxxx/xxxx/node_global"
as well
NPM configSetCache"Xxx/xxxx\node_cache"

Step three: Install the relevant environment

  • NPM Install Express-g

  • npm Install express-generator-g (because I installed 4.X so to install this otherwise express-v will be reported not internal command )

  • NPM Install Jade-g

  • NPM Install Mysql-g

    

All commands are globally installed (that is, the "xxx/xxx/node_global" set above) so that the installed packages are available under the current user and are accessible from all other locations on the disk. Comparative aspect. Otherwise, it is installed in the current directory and can only be used in the current directory.

Example:

Fourth Step: Configure environment variables

    • Because the module's default address is changed, the above user variables are changed (user variable "PATH" is modified to "C:\Program files\nodejs\node_global\"), or the use of module will cause the input command to appear " XXX is not an internal or external command, nor is it a program or batch file that can be run "this error.

    • Close cmd, open System dialog, "My Computer" right "properties"-"Advanced system Settings"-"Advanced"-"Environment variables".

Such as:

 

Enter the Environment Variables dialog box and create a new "Node_path" value under System variables: xxx/xxx/node_global/node_modules

(PS: This step is important, otherwise it will be reported that XXX is not an internal command)


Fifth step: Create a project

    • Create a App.js file

var http = require ("http"); Http.createserver (function (request, response) {Response.writehead (), {"Content-type": "      Text/plain "});      Response.Write ("Hello World"); Response.End ();}). Listen (8888); Console.log ("Nodejs Start listen 8888 port!");

    • Node App.js

    • http://127.0.0.1:8888/

    • Discovery Output Hello World


NODEJS Environment Construction

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.