public:computer:node.js

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revisionBoth sides next revision
public:computer:node.js [2022/09/16 16:06] – [typescript] alexpublic:computer:node.js [2023/01/02 16:55] – [Install Node.js on Ubuntu] alex
Line 4: Line 4:
  
 ==== 특징 ==== ==== 특징 ====
-  * 비동기 입출력 방식 +  * 비동기 입출력 방식 (Non-blocking) I/O 
-  * 이벤트 기반 입출력 방식+  * 이벤트 기반 입출력 방식 (Event Loop) 
 +  * Single Thread
   * 모듈   * 모듈
  
 ==== 개발도구 ==== ==== 개발도구 ====
   * 편집기 VSCode   * 편집기 VSCode
 +    * Extentions
 +      * ES6 Code Snippets
 +      * ESLint
 +      * Prettier - Code formatter
 +      * Live Server
   * 크롬 브라우저   * 크롬 브라우저
   * 노드   * 노드
Line 27: Line 33:
 or or
 $ yarn global add @vue/cli $ yarn global add @vue/cli
 +or
 +$ yarn dlx @vue/clie
  
 $ vue --version  # 확인 $ vue --version  # 확인
Line 59: Line 67:
 </cli> </cli>
  
 +=== Install Node.js on Ubuntu ===
 +  * Install Node.js on Ubuntu <sxh bash>
 +# to install node.js we need CURL
 +$ sudo apt install -y curl
 +
 +# install node.js using apt package manager
 +$ sudo apt update & sudo apt upgrade -y
 +$ sudo apt install nodejs
 +$ nodejs -v
 +$ sudo apt install npm
 +$ npm -v
 +
 +# using PPA
 +$ curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh  # version 18.x
 +$ sudo bash nodesource_setup.sh 
 +$ sudo apt-get install nodejs
 +$ sudo apt-get install build-essential
 +</sxh>
 +
 +  * nvm <sxh bash>
 +$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
 +$ source ~/.bashrc
 +$ nvm list-remote
 +$ nvm install <version>
 +$ nvm list
 +$ nvm use <version>
 +</sxh>
 +  * npm update <sxh bash>
 +$ npm install -g npm@latest
 +$ npm -v
 +</sxh>
 +
 +
 +==== Modules ====
  
   * https/http2 모듈   * https/http2 모듈
Line 115: Line 157:
  
  
 +==== JavaScript Basics ====
 +  * 변수 선언
 +    * var
 +    * let
 +    * const
 +  * Arrow Function
 +  * Array
 +    * sort()
 +    * filter()
 +    * map()
 +    * reduce()
 +  * Template Literals; back tick ''`''
 +  * Spread Operator; 배열에서 iteration 형태의 데이터 요소를 하나하나로 모두 분해해서 사용
 +  * Object Destructuring; { , } = object
 +  * Array Destructuring; [ , ] = array
 +  * Default Function Parameter; same as c++, define default value in argument
 +  * Rest Parameter; ...args
 +  * Promise; 비동기 처리에 사용 new Promise((resolve, reject) => {}});
 +  * Async/Await; 비동기
 +  * Regular Expression
 +    * exec()
 +    * test()
 +    * match()
 +    * search()
 +    * replace()
 +    * split()
 +
 +
 +==== Start ====
 +<cli>
 +$ node <file>
 +</cli>
 +
 +
 +==== Node.js 내장 모듈과 객체 ====
 +  * Console
 +    * console.log(내용, ...args)
 +    * console.error(...)
 +    * console.table(테이블형 데이터)
 +    * console.time(레이블) / console.timeEnd(레이블)
 +    * console.dir(오브젝트, 옵션)
 +  * Timers
 +    * setTimeout(콜백함수, 밀리초)
 +    * setInterval(콜백함수, 밀리초)
 +    * setImmediate(콜백함수)
 +  * Process
 +    * listeners
 +      * beforeExit
 +      * exit
 +      * disconnect
 +      * message
 +    * process.env
 +    * process.nextTick
 +    * process.exit()
 +  * OS
 +  * Path
 +    * path.basename(path[,ext])
 +    * path.delimiter
 +    * path.dirname(path)
 +    * path.extname(path)
 +    * path.format(pathOjbject)
 +    * path.isAbsolute(path)
 +    * path.join([...paths])
 +    * path.parse(path)
 +    * path.sep
 +  * URL; 
 +    * WHATWG API
 +    * url.parse()
 +  * Crypto
 +  * File system
 +    * fs.readFile(path, [options], callback)
 +    * fs.readFileSync(path, [options])
 +    * fs.writeFile(path, data, [options], callback)
 +    * writeFileSync(path, data [options])
 +    * fs.watchFile(filename[, options], listener)
 +
 +
 +==== json-server ====
 +<cli>
 +$ npm install -g json-server
 +</cli>
 +
 +<cli>
 +$ json-server --watch <file>
 +</cli>
 +
 +==== express ====
 +<cli>
 +$ npm install express
 +</cli>
 +
 +  * middlewares
 +    * body-parser
 +    * compression
 +    * connect-rid
 +    * cookie-parser
 +    * cors
 +    * csurf
 +    * errorhandler
 +    * method-override
 +    * morgan
 +    * multer
 +    * response-time
 +    * serve-favicon
 +    * serve-index
 +    * serve-static
 +    * express-session
 +    * connect-timeout
 +    * vhost
 +
 +
 +==== Useful ====
 +  * winston
 +  * nodemailer
 +  * node-cron
 +  * xlsx
 +  * xlsx-js-style
 +  * ics
 +  * socket.io
 +  * axios
 +  * cheerio
 +  * forever
 +  * pm2
 +
 +===== References =====
 +  * [[https://github.com/nvm-sh/nvm|Node Version Manager]]
 +
 +
 +<button type="default" size="xs" collapse="toc">book toc</button>
 +<collapse id="toc" collapsed="true">
 ==== 01 | 노드에 대해 알아보고 개발 도구 설치하기 ==== ==== 01 | 노드에 대해 알아보고 개발 도구 설치하기 ====
 노드란 무엇일까? 노드란 무엇일까?
Line 421: Line 593:
 레디스로 subscribe, publish 하기 레디스로 subscribe, publish 하기
 채팅 서버에서 레디스를 사용하는 샘플 채팅 서버에서 레디스를 사용하는 샘플
 +</collapse>
  • public/computer/node.js.txt
  • Last modified: 2023/01/03 09:54
  • by alex