Introduction to Node.js(2)
Introduction to Node.js(2)
- by Poechant (blog.csdn.net/poechant)
1 How to recognize your Node.js files?
Node-js
|--- index.js
|--- server.js
index.js:
var server = require("./server.js");
server.start();
server.js:
var http = require("http");
function start() {
http.createServer(function(request, response) {
console.log("Receive a request.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8765, "127.0.0.1");
}
exports.start = start;
2 How to install an external module?
It’s very very easy. The only requirement is that your computer has been connected to Internet. The method to install Node.js modules is just like the way to install softwares on Linux using apt-get, or on Mac OS X using marport.
npm install SOME_MODULE
What does npm stand for?
Perhaps it is NodeJS Pakage Management.
3 How to use a module?
I guess you’ve already known that.
var yourModule = require("./someModule.js");
or
var module = require("module");
-
轉載請註明來自柳大的CSDN部落格:blog.csdn.net/poechant
-
相關文章
- Introduction to Node.js(1)Node.js
- [轉]Introduction to JAIN SIP API part2AIAPI
- Introduction to pinatrace annotate version 2: a look into latches againAI
- Introduction to AlgorithmGo
- Introduction to GitGit
- RL Introduction
- [Java] Introduction to Java Programming 筆記: Chapter 2. 基礎Java筆記APT
- TLS 1.3 IntroductionTLS
- nodejs introductionNodeJS
- Chapter 1:IntroductionAPT
- Introduction to Partitioning
- No Sql Db IntroductionSQL
- Hadoop IntroductionHadoop
- Introduction to Databases and MySQLDatabaseMySql
- Oracle RAC introductionOracle
- HTML 01 - IntroductionHTML
- Introduction to Vetors
- Introduction of DataGuard protection mode
- A re-introduction to JavaScriptJavaScript
- [zz]android introductionAndroid
- Introduction to Index Segments (24)Index
- FFmpeg Filtering IntroductionFilter
- <node.js學習筆記(2)>Node.js筆記
- 1 Introduction to the Multitenant ArchitectureNaN
- Machine Learning-IntroductionMac
- A gentle introduction to multithreadingthread
- Introduction to ASP.NET 5ASP.NET
- An Introduction to the Basics of Modern CSS ButtonsCSS
- Introduction to an Oracle Instance (284)Oracle
- Visitor Pattern Introduction (轉)
- Introduction to Schema Objects (153)Object
- Introduction to Oracle Memory Structures (69)OracleStruct
- HMAC: Introduction, History, and ApplicationsMacAPP
- EESA01 Introduction to Environmental
- [譯]當 Node.js Core 遇到 HTTP/2Node.jsHTTP
- 使用 HTTP/2 加速 Node.js 應用HTTPNode.js
- 2、Node.js 第一個應用Node.js
- 我與Node.js重新認識的第2周 - Node.js 底層Node.js