Home Web Front-end JS Tutorial How to install Node.js modules on Windows

How to install Node.js modules on Windows

Dec 26, 2016 am 09:34 AM
node.js

However, 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 version of Node.js Windows executable program:
http://nodejs.org/#download
I used version 0.5.7 in the experiment: 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 c:nodejsnode_modules directory, and create [Module] directories respectively in this directory. Then compress the file downloaded in the previous step and copy the relevant files to the [Module] directory.
node_modules
|- connect <= connect: lib/*
|- express <= express: lib/*
|- jade <= jade: lib/*
|- mime <= mime: mime.js & types/*
|- qs <= qs: lib/*

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. Compress the downloaded express Copy the bin/express file in the package to the c:nodejs directory and rename it 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 the browser: http://localhost:3000 to view the results.

The test is now complete.
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.

For more related articles on how to install Node.js modules on Windows, please pay attention to the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed graphic explanation of the memory and GC of the Node V8 engine Detailed graphic explanation of the memory and GC of the Node V8 engine Mar 29, 2023 pm 06:02 PM

This article will give you an in-depth understanding of the memory and garbage collector (GC) of the NodeJS V8 engine. I hope it will be helpful to you!

An article about memory control in Node An article about memory control in Node Apr 26, 2023 pm 05:37 PM

The Node service built based on non-blocking and event-driven has the advantage of low memory consumption and is very suitable for handling massive network requests. Under the premise of massive requests, issues related to "memory control" need to be considered. 1. V8’s garbage collection mechanism and memory limitations Js is controlled by the garbage collection machine

Let's talk about how to choose the best Node.js Docker image? Let's talk about how to choose the best Node.js Docker image? Dec 13, 2022 pm 08:00 PM

Choosing a Docker image for Node may seem like a trivial matter, but the size and potential vulnerabilities of the image can have a significant impact on your CI/CD process and security. So how do we choose the best Node.js Docker image?

Let's talk in depth about the File module in Node Let's talk in depth about the File module in Node Apr 24, 2023 pm 05:49 PM

The file module is an encapsulation of underlying file operations, such as file reading/writing/opening/closing/delete adding, etc. The biggest feature of the file module is that all methods provide two versions of **synchronous** and **asynchronous**, with Methods with the sync suffix are all synchronization methods, and those without are all heterogeneous methods.

Node.js 19 is officially released, let's talk about its 6 major features! Node.js 19 is officially released, let's talk about its 6 major features! Nov 16, 2022 pm 08:34 PM

Node 19 has been officially released. This article will give you a detailed explanation of the 6 major features of Node.js 19. I hope it will be helpful to you!

Let's talk about the GC (garbage collection) mechanism in Node.js Let's talk about the GC (garbage collection) mechanism in Node.js Nov 29, 2022 pm 08:44 PM

How does Node.js do GC (garbage collection)? The following article will take you through it.

Let's talk about the event loop in Node Let's talk about the event loop in Node Apr 11, 2023 pm 07:08 PM

The event loop is a fundamental part of Node.js and enables asynchronous programming by ensuring that the main thread is not blocked. Understanding the event loop is crucial to building efficient applications. The following article will give you an in-depth understanding of the event loop in Node. I hope it will be helpful to you!

What should I do if node cannot use npm command? What should I do if node cannot use npm command? Feb 08, 2023 am 10:09 AM

The reason why node cannot use the npm command is because the environment variables are not configured correctly. The solution is: 1. Open "System Properties"; 2. Find "Environment Variables" -> "System Variables", and then edit the environment variables; 3. Find the location of nodejs folder; 4. Click "OK".

See all articles