How to install Node.js modules on Windows_javascript tips
May 16, 2016 pm 06:01 PMHowever, there is news that Microsoft has contacted Node.js officials, and I believe there will be improvements soon.
So without installing Cygwin, is it possible to set up a Node.js environment on Windows for experimental development? I did a simple test using Node.js express, and it is basically feasible.
The steps are as follows:
1. Download the official non-stable Windows executable program of Node.js:
http://nodejs.org/#download
I used 0.5 in the experiment .7 version: http://nodejs.org/dist/v0.5.7/node.exe
2. Create the c:nodejs directory and save node.exe in this directory
3. Download express. Because of dependencies, we also need to download: connect, qs, mime and jade (express default template system. If you use other template systems, you need to download the corresponding system)
Name Address Experimental Version
------ -------------------------------------------------- -------
express: https://github.com/visionmedia/express 2.4.3
connect: https://github.com/senchalabs/connect 1.7.1
qs: https://github.com/visionmedia/node-querystring 0.3.1
mime: https://github.com/bentomas/node-mime 1.2.4
jade: https://github.com/ visionmedia/jade 0.15.4
4. Create the c:nodejsnode_modules directory, and create [Module] directories in this directory. Then compress the file downloaded in the previous step and copy the relevant files to the [Module] directory.
node_modules
|- connect |- express |- jade |- mime |- qs
5. In the c:nodejsnode_modules directory, create the following files:
connect.js
Content: module.exports = require('./connect/connect');
express.js
Content: module.exports = require('./express/express');
jade.js
Content: module.exports = require('./jade/jade');
mime.js
Content: module.exports = require('./mime/mime');
qs .js
Content: module.exports = require('./qs/querystring');
6. Copy the bin/express file in the downloaded express compressed package to the c:nodejs directory, and Rename to express.js
7. Modify the express.js file, taking 2.4.3 as an example below:
7.1. Modify the mkdir function body
401: exec('mkdir -p ' path, function(err){
->exec('md ' path, function(err){
7.2. Modify mkdir function call
263: mkdir(path '/public/javascripts');
->mkdir(path '\public\javascripts');
264: mkdir(path '/public/images');
->mkdir(path '\public\images');
265: mkdir(path '/public/stylesheets', function(){
->mkdir(path '\public\stylesheets', function(){
280: mkdir(path '/views', function(){
->mkdir(path '\views', function(){
8. Create an express project:
c:nodejsnode.exe express.js -s hello
9. c:nodejsnode_modules*.* => c:nodejshellonode_modules
10. Run and test:
c:nodejsnode.exe helloapp.js
Open in browser: http://localhost :3000 to view the results.
The test is now completed.
The test file is given below. In the test file, I also tested express session. You can open it in the browser: http://localhost:3000/session to view the results.
Test file: nodejs.rar

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

An article about memory control in Node

Detailed graphic explanation of the memory and GC of the Node V8 engine

Node.js 19 is officially released, let's talk about its 6 major features!

Let's talk in depth about the File module in Node

What should I do if node cannot use npm command?

Let's talk about how to choose the best Node.js Docker image?

Let's talk about the GC (garbage collection) mechanism in Node.js

Let's talk about the event loop in Node
