node - deptno/deptno.github.io GitHub Wiki

node

javascript runtime a.k.a nodejs

options

--max-old-space-size --max-new-space-size --require [file.js] --enable-source-maps --es-module-specifier-resolution=[node] # node 의 κ²½μš°μ—λŠ” esmodule 파일의 ν™•μž₯자λ₯Ό λͺ…μ‹œν•˜μ§€ μ•Šμ•„λ„ import κ°€ κ°€λŠ₯ node@19 λΆ€ν„°λŠ” 제거될 μ˜ˆμ •

esmodule

  • __filename -> import.meta.url
  • __dirname -> path.dirname(import.meta.url)

error

ECONNRESET

Error: Client network socket disconnected before secure TLS connection was established
    at connResetException (internal/errors.js:609:14)
    at TLSSocket.onConnectEnd (_tls_wrap.js:1536:19)
    at Object.onceWrapper (events.js:421:28)
    at TLSSocket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'ECONNRESET',

ERR_OSSL_EVP_UNSUPPORTED

Failed to construct transformer:  Error: error:0308010C:digital envelope routines::unsupported
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

node18μ—μ„œλŠ” μ‹€ν–‰μ•ˆλ˜κ³  node 16μ—μ„œ 싀행됨 μ–΄λ–€ 것 λ•Œλ¬ΈμΈμ§€λŠ” 찾아보지 μ•ŠμŒ

Internal Error: spawn Unknown system error -8

package.json 의 scriptμ—μ„œ μ‰˜μŠ€ν¬λ¦½νŠΈλ₯Ό μ‹€ν–‰ν•˜λŠ” κ²½μš°μ— λ°œμƒ #!/usr/bin/env bash 와 같이 μ΅œμƒλ‹¨ 라인에 μ‰˜μ„ λͺ…μ‹œν•΄μ£Όλ©΄ ν•΄κ²°λœλ‹€

Internal Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at Object.spawn (node:child_process:757:9)
    at YK (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:4:6994)
    at uh.implementation (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:392:17802)
    at uh.exec (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:395:1585)
    at uh.run (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:395:1756)
    at I7 (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:401:6331)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async WRe (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:403:16)
    at async o (/Users/deptno/.cache/node/corepack/yarn/3.3.1/yarn.js:403:146)

디버깅

memory leak

cross-env NODEOPTIONS=--inspect ts-node .

inspect μ˜΅μ…˜μœΌλ‘œ 덀프λ₯Ό μƒμ„±ν•΄μ„œ λ©”λͺ¨λ¦¬ 좔적이 κ°€λŠ₯ν•˜λ‹€.

λ””λ°”μ΄μŠ€ 디버깅

ν¬λ‘¬μ—μ„œ 확인이가λŠ₯

  • chrome://inspect/#devices

접속 ν›„ μΈμŠ€νŽ™ν„°λ₯Ό μ—΄λ©΄ λ©”λͺ¨λ¦¬ 탭이 μ‘΄μž¬ν•˜κ³  μ—¬κΈ°μ„œ μ‹€μ‹œκ°„μœΌλ‘œ 증가와 κ°μ†Œ 확인이 κ°€λŠ₯

μ„±λŠ₯ν…ŒμŠ€νŠΈ

λΆ€ν•˜ ν…ŒμŠ€νŠΈ

νŠΉμ • νŽ˜μ΄μ§€λ₯Ό μ§€μ†μ μœΌλ‘œ ν•΄μ„œ tps 츑정이 κ°€λŠ₯ν•˜λ‹€.
이와 ν•¨κ»˜ 크둬의 λ©”λͺ¨λ¦¬ 탭을 ν™•μΈν•΄μ„œ λ ˆμ½”λ”©μ„ κ±Έκ³  λΆ€ν•˜ν…ŒμŠ€νŠΈλ₯Ό ν•œ ν›„ gc κ°€ λŒκ³ λ‚˜μ„œλ„ λ©”λͺ¨λ¦¬κ°€ μ›λž˜λ˜λ‘œ λŒμ•„μ˜€μ§€ μ•ŠλŠ”μ§€ 확인이 ν•„μš”ν•˜λ‹€.

link