Node.js Tutorial for Beginners
1. What is Node
2. Node Architecture
it's a runtime environment for executing javascript code.
3. How Node Works
non-blocking or asynchronous
blocking or synchronous
Node is ideal for I/O-intensive apps.
Do not use Node for CPU-intensive apps.
4. Installing Node
Node.js Download
5. Your First Node Program
function sayHello(name) {
console.log('Hello '+name);
}
sayHello('Karam');
[実行結果]node app.jsHello Karam
6. Node Module System
7. Global Object
// global.변수명
global.setTimeout()
global.clearTimeout();
global.setInterval();
global.clearInterval();
8. Modules
// app.js
console.log(module);
[実行結果]node app.jsModule {
id: '.',
path: 'C:\\workspace\\first-app',
exports: {},
parent: null,
filename: 'C:\\workspace\\first-app\\app.js',
loaded: false,
children: [],
paths: [
'C:\\workspace\\first-app\\node_modules',
'C:\\workspace\\node_modules',
'C:\\node_modules'
]
}
9.Creating a Module
// logger.js
var url = 'http://mylogger.io.log';
function log(message){
// Send an HTTP request
console.log('hello, log message is ' + message);
}
module.exports.log = log;
10. Loading a Module
//app.js
var logger = require('./logger');
console.log(logger);
logger.log('message');
[実行結果]node app.js{ log: [Function: log] }
hello, log message is message
export a single function or an object// logger.js
var url = 'http://mylogger.io.log';
function log(message){
// Send an HTTP request
console.log('hello, log message is ' + message);
}
module.exports = log;
// app.js
const log = require('./logger'); // var가 아닌 const를 사용하는 이유: 변수의 재할당을 막기 위해서
log('message');
[実行結果]node app.jshello, log message is message
更新
11. Module Wrapper Function
12. Path Module
13. OS Module
14. File System Module
15. Events Module
16. Event Arguments
17. Extending EventEmitter
18. HTTP Module
注意事項
Node.js Tutorial for Beginners: Learn Node in 1 Hour
Reference
この問題について(Node.js Tutorial for Beginners), 我々は、より多くの情報をここで見つけました https://velog.io/@krhong/Node.js-Tutorial-for-Beginnersテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol