*
1,下载路径
https://nodejs.org/en/download/
2,安装 express(之前用npm install -g express,一直提示出错,然后查资料说nodejs如果是4以上,
应该用express-generator)
D:\Resources\NODEJS\nodejs>npm uninstall -g express
npm WARN uninstall not installed in D:\Resources\NODEJS\nodejs\node_modules: "express"
D:\Resources\NODEJS\nodejs>npm install -g express-generator
D:\Resources\NODEJS\nodejs\express -> D:\Resources\NODEJS\nodejs\node_modules\express-generator\bin\express
[email protected] D:\Resources\NODEJS\nodejs\node_modules\express-generator
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected])
D:\Resources\NODEJS\nodejs>express -V
4.13.4
//创建helloworld的项目
D:\Resources\NODEJS\nodejs>express helloworld
create : helloworld
create : helloworld/package.json
create : helloworld/app.js
create : helloworld/public/javascripts
create : helloworld/public/images
create : helloworld/public/stylesheets
create : helloworld/public/stylesheets/style.css
create : helloworld/routes
create : helloworld/routes/index.js
create : helloworld/routes/users.js
create : helloworld/public
create : helloworld/views
create : helloworld/views/index.jade
create : helloworld/views/layout.jade
create : helloworld/views/error.jade
create : helloworld/bin
create : helloworld/bin/www
*************helloworld.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:\Resources\NODEJS\nodejs>cd helloworld
D:\Resources\NODEJS\nodejs\helloworld>node helloworld.js
nodejs start listen 8888 port!
打开地址http://127.0.0.1:8888/
发现输出 :
Hello World
来自 <http://www.cnblogs.com/pigtail/archive/2013/01/08/2850486.html>
*****************
1,cmd窗口,输入node,回车,输入"console.log("hello")",可以简单测试node.js
*