NodeJs環境配置

來源:互聯網
上載者:User

標籤:list   jad   log   nodejs   text   art   hive   object   asc   

*

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

 

*

NodeJs環境配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.