node.js 安装、图文详解

时间:2023-03-09 03:49:32
node.js 安装、图文详解

网上的教程很多,有些模糊不清,有些版本太旧,有些是.exe安装,本文讲述windows系统下简单nodejs .msi环境配置。最新版是Current version: v0.10.26。官网下载地址:http://nodejs.org/download/。本人新手,有不尽如人意或是错误的地方,还请见谅和指正。

1、下载,最新版是Current version: v0.10.26

node.js 安装、图文详解

根据需要下载.msi版本,本机win7系统 选择64-bit

2、安装。默认c盘,也可以切换到其他盘,安装的时候npm默认选择即可。

node.js 安装、图文详解

node.js 安装、图文详解

3、测试

打开cmd,直接输入node -v 如果返回 v0.10.26,说明安装正确

node.js 安装、图文详解

4、test.js

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!");

d盘新建node文件夹,新建test.js,内容为以上代码

cd进入d盘dode文件夹,执行test.js

node.js 安装、图文详解node.js 安装、图文详解

一切就绪