예시 'use strict'; const nconf = require('nconf'); const models_maria = require(nconf.get('models_maria')); module.exports = async function(outCallback) { try { await models_maria.db.sync(); outCallback(null, '==> MariaDb Connect Complete!!!\n'); } catch (err) { outCallback(err); } }; 모듈과 라이브러리 불러오기 필요한 모듈과 라이브러리를 불러온다. 여기서는 구성 관리를 위한 nconf 라이브러리와 MariaDB와의 연결을 관리하기 위한 사용자 정의 모듈 models_maria를 사용한다..
npm install --save npm install --save npm install --save는 node_modules에 패키지를 설치하고 package.json의 dependencies 항목에 있는 플러그인 정보가 저장된다. --production 옵션으로 실행 시 반드시 해당 플러그인이 포함된다. # package.json dependencies "dependencies": { "@web3-react/abstract-connector": "^6.0.7", "@web3-react/types": "^6.0.7", "async": "^2.6.2", "bignumber.js": "latest", "body-parser": "latest", "bsc": "^2.0.0", "chalk": "^2.4.2"..
pm2 Node.js 어플리케이션을 실행하는 경우 node app.js 와 같은 node 실행 명령어나 백그라운드로 실행시키고 싶을 경우 nohup으로 실행했던 경험이 있을 것이다. # node 실행 node app.js 해당 경험을 가지고 있는 사람들이 Node.js 어플리케이션을 실행하는 경우 편리하게 관리할 수 있는 패키지다. pm2는 Node.js 어플리케이션을 위한 프로세스 관리자이며, 로드 밸런서가 빌트인 되어있다. pm2 설치 nvm 설치 pm2를 설치하려면 우선 nvm을 설치해야 한다. https://github.com/nvm-sh/nvm 에서 명령어 확인 가능하다. wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/instal..
오류 npm cache clean --force 명령어 오류 npm WARN using --force Recommended protections disabled. 해결방법 npm 버전을 변경한 후에 command 재실행 6.14.11을 원하는 버전으로 변경 후 설치 npm install -g npm@6.14.11