목록Language/Node.js (7)
미니옵빠의 code stubs
Node 에서 log4js 를 사용하고, pm2 cluster 모드 사용 시 log4js 로그가 출력되지 않는 현상이 있음. pm2-intercom 을 활용하여 해결. pm2 worker 에서는 log4js 출력이 되지 않고, master 프로세스에서만 출력 된다고 합니다.pm2-intercom 에서 logEvent 를 받아 모든 프로세스로 broadcast 해준다고 하네요. 아래 그림 참고. 그림 ref: https://github.com/log4js-node/log4js-node/issues/547#issuecomment-385136125 설정 ref예시: https://gist.github.com/nomiddlename/99b7530281debc926d5e7b8a3b87350flog4js Confi..
Windows 환경에서 node-gyp build 시 오류가 나는 경우가 있음.node-gyp 으로 모듈을 직접 만드는 경우가 아니라면, 대부분 heapdump 같은 library install 시 만나게 됨 gyp info spawn args [ 'C:\\Program Files (x86)\\Yarn\\node_modules\\node-gyp\\gyp\\gyp_main.py',gyp info spawn args 'binding.gyp',gyp info spawn args '-f',gyp info spawn args 'msvs',gyp info spawn args '-G',gyp info spawn args 'msvs_version=auto',gyp info spawn args '-I', -- 중략 gy..
Node.js 8 버전에 inspector 기능이 추가되었습니다. (사실은 7부터)이제는 디버깅을 더 쉽게 할 수 있습니다. https://nodejs.org/en/docs/inspector/ node 실행 시 --inspect 옵션만 주면 됩니다. 사용법 1. node --inspect xxx.js 실행. 아래 로그 확인Debugger listening on ws://127.0.0.1:9229/29ff9e93-e137-49b8-ab6e-25b2c924c225For help see https://nodejs.org/en/docs/inspectorThe server is running at https://localhost:9000/ 2. Chrome 브라우저 > chrome://inspect/#device..
나온지는 좀 되었지만.. New Featureshttps://nodejs.org/en/blog/release/v8.0.0/#improved-support-for-promises 성능 향상V8 engine 성능 향상. v6.1 < v5.1 Turbofan + Ignition compiler pipeline 사용. https://v8project.blogspot.kr/2017/05/launching-ignition-and-turbofan.htmlhttps://hackernoon.com/upgrading-from-node-6-to-node-8-a-real-world-performance-comparison-3dfe1fbc92a3https://hackernoon.com/whats-new-with-server-s..
Node.js addonNode.js Addons are dynamically-linked shared objects, written in C++, that can be loaded into Node.js using the require() function, and used just as if they were an ordinary Node.js moduleC / C++ 라이브러리를 Node.js에서 module 형태로 사용가능합니다.addon 작성 기초node-gyp를 이용한 기본 사용법은 아래를 참고하면 됩니다. c++ 샘플 파일 작성부터 build, node.js 모듈로 사용법까지 잘 설명되어 있습니다.Node.js v8.1.2 Documentation: https://nodejs.org/api/a..
consolo.log(Object) 로 디버그 시 '[Object]' 처럼 출력되고 더 깊은 depth의 데이터는 출력되지 않음.이럴 땐 util.inspect() 를 사용. 이렇게. const util = require('util') console.log(util.inspect(myObject, {showHidden: false, depth: null})) // alternative shortcutconsole.log(util.inspect(myObject, false, null)) 참고https://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-jss-console-log-rather-than-object 주의my..
한 PC에서 여러 nodejs 버전을 사용하고 싶을 경우, NVM (Node Version Manager) 을 활용한다. Linux: https://github.com/creationix/nvm#manual-installWindows: https://github.com/coreybutler/nvm-windows gulp 등을 사용하다보면, 각 모듈이 nodejs 버전을 타는 경우가 있다.여러 프로젝트를 동시에 구현할 때 유용