반응형

개요

yargs 에서 임의로 help를 출력해주고 싶을 때 사용한다

코드

const yargs = require('yargs');

const argv = yargs
    .command('lyr', 'Tells whether an year is leap year or not', {
        year: {
            description: 'the year to check for',
            alias: 'y',
            type: 'number',
        }
    })
    .option('time', {
        alias: 't',
        description: 'Tell the present Time',
        type: 'boolean',
    })
    .help()
    .alias('help', 'h')
    .argv;
    
yargs.showHelp();
반응형

'javascript' 카테고리의 다른 글

[puppeteer] No usable sandbox  (0) 2020.02.21
[javascript] if number 조건일 때 주의  (0) 2020.01.09
[javascript] array - includes()  (0) 2019.12.09
반응형

문제

서버 환경(centos7)에서 실행하니 error 발생

 

UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[0220/171512.042961:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

 

해결 방법

const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox']
})

 

반응형

'javascript' 카테고리의 다른 글

[Javascript][yargs] show/print help  (0) 2020.02.21
[javascript] if number 조건일 때 주의  (0) 2020.01.09
[javascript] array - includes()  (0) 2019.12.09
반응형

자바스크립트 if 문의 조건문에 확인하려는 값이 number 일 때

 

const number = -1;

if (number) {
  console.log("true");
} else {
  console.log("false");
}

 

결과 값은 무엇일까?

 

결과는

true

if 문 안에 number 결과값을 줄 때는

 

if (number > 0) {
  ...
} else {
  ...
}

 

이런 식으로 정확히 양수 검사를 해주어야 한다

 

반응형

'javascript' 카테고리의 다른 글

[Javascript][yargs] show/print help  (0) 2020.02.21
[puppeteer] No usable sandbox  (0) 2020.02.21
[javascript] array - includes()  (0) 2019.12.09
반응형

javascript 리스트 안에 특정 요소가 있는지 확인하는 방법

 

소스코드

 

const list = [237, 238, 239, 240, 242, 243];
const item = 237;

for(let i = 0; i < list.length; i++){
 if( list.includes(item)){
  alert("exists");
 }
}

 

 

반응형

'javascript' 카테고리의 다른 글

[Javascript][yargs] show/print help  (0) 2020.02.21
[puppeteer] No usable sandbox  (0) 2020.02.21
[javascript] if number 조건일 때 주의  (0) 2020.01.09

+ Recent posts