如何安裝Node.js環境


一、在Windows系統下安裝Node.js環境

1.   下載地址:官網http://nodejs.org/

2.    安裝nodejs,根據自己情況,安裝路徑 D:\Program Files\nodejs

3.  安裝相關環境

安裝express需要調用 npm install express -g

Or直接修改全局路徑

npm config set prefix "D:\Program Files\nodejs"

npm config set cache "D:\Program Files\nodejs\webapp_cache" (先建好webapp_cache目錄)

鍵入:express socialserver (socialserver是隨意起的工程名稱)

在myserver里自動創建public、routes、views、app.js、package.json這幾文件。

在myserver下新建helloworld.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

鍵入node helloworld.js

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM