Simple NODEJ.S Environment Configuration installation under Windows system

Source: Internet
Author: User

At present the highest concern in China, the best maintenance of a website about Nodejs should be http://www.cnodejs.org/

Simple NODEJS environment configuration under Windows System.

First step: Download the installation file

: Official website https://nodejs.org/en/download/

It's used here.

Step Two: Install Nodejs

After the download is complete, double-click Node-v6.9.1-x64.msi to start installing Nodejs, which is installed by default under C:\Program Files\nodejs

Step three: Install the relevant environment

Open the C:\Program Files\nodejs directory you'll find it comes with NPM, which is installed directly with NPM

Open windows comes with DOS window win+r, enter CMD, return

Type the command: CD C:\Program Files\nodejs can be

Start installing the relevant environment now

Type the command: NPM install express-g Enter wait to install Express .....

Type the command: NPM install jade Enter to wait for the installation of Jade ....

Type the command: NPM install MySQL Enter to wait for the installation of MySQL ....

........ What components to install, depending on the environment to build the requirements

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

Fourth step: Create a project

If you find that there are no express and express.cmd two files in the C:\Program Files\nodejs directory after you install the above components, follow the command npm install Express-generator

(Because the express default installation is the latest version, it is already a 4.x.x version.) The command tool is split in the latest version of express4.0+, so you have to install express-generator)

Now there's an express

The Express command is installed at the Global to work!

So express installs with NPM install Express-g

or modify the global path directly:

NPM config set prefix "C:\Program Files\nodejs"

NPM config set cache "C:\Program Files\nodejs\cache" (the cache directory is built first)

Type: Express MyApp (MyApp is a random project name)

You'll find one more C:\Program. Files\nodejs\myapp Directory

By default: It is automatically created

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

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

Enter the node. js Command Prompt Commands window and enter the C:\Program Files\nodejs\myapp directory

Type node Helloworld.js

Open Address http://127.0.0.1:8888/

Discovery Output:

Hello World

Global mode and local mode installation issues resolved:

Global mode:
After installing Express and Express-generator in the path:

C:\Program Files\nodejs generates Express, express.cmd two files.

Local mode:
After installing Express and Express-generator in the path: D:\TOOLS\NodeJs did not generate Express, express.cmd two files. And in the path:

C:\Program Files\nodejs\node_modules There is a. bin (generated when installing express-generator), there are express, express.cmd two files.

Then add it in the system environment variable path: C:\Program files\nodejs\node_modules\.bin

Try execution again:
C:\Program files\nodejs>express-v

Simple NODEJ.S Environment Configuration installation under Windows system

Related Article

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.