At present, the highest concern in China, the maintenance of the best one about Nodejs website should be http://www.cnodejs.org/
Simple NODEJS environment configuration under Windows System.
First step: Download the installation files
Download Address: 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, start installation Nodejs, default is installed under C:\Program Files\nodejs
Step three: Install the relevant environment
Open the C:\Program Files\nodejs directory you'll find that it's got npm in it, and you can use NPM to install the environment directly
Open windows with a DOS window win+r, enter CMD, return
Type command: CD C:\Program Files\nodejs can
Start the installation of the relevant environment now
Type command: NPM install express-g carriage return waiting to be installed express ...
Type command: NPM install Jade Carriage return waits to install jade ...
Type command: NPM install MySQL carriage return waiting to install MySQL ...
........ What components to install, depending on the environment to build requirements
By default, these components are installed under the C:\Program Files\nodejs\node_modules folder, which is also the automatic lookup path for NODEJS related components
Step Fourth: Create a project
If you find that there are no express and express.cmd two files in the C:\Program Files\nodejs directory after installing the above components, execute the command npm install Express-generator
(due to the express default installation is the latest version, is already a 4.x.x version.) The command tool is separated from the latest express4.0+ version, so you must install Express-generator
Now there's the Express
Express commands are installed in the global only to work!
So express installation will use 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" (first built cache directory)
Type: Express MyApp (MyApp is a random project name)
You'll find one more C:\Program Files\nodejs\myapp directory
By default: automatically creates
Copy Node_modules to MyApp below
The environment is built to this completion, the following do a demo test!
Create a new helloworld.js under MyApp
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!");
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 problem Resolution:
Global mode:
Install Express and Express-generator after 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 in the System environment variable path: C:\Program files\nodejs\node_modules\.bin
Try to execute again:
C:\Program files\nodejs>express-v
The above is a small series to introduce the Windows system under the Node.js environment configuration and installation of the tutorial graphics and text, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!