option ‘–open ‘ argument missing

window에서 개발할때 발생한 트러블 슈팅

문제상황

webpack, webpack-cli, webpack-dev-server를 깔고, 공식사이트에 나온대로 webpack serve --open 를 쳤습니다. 근데 다음과 같은 에러가 나왔습니다.

error: option '--open <value>' argument missing
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hooks@1.0.0 start: `webpack serve --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hooks@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\W24946\AppData\Roaming\npm-cache\_logs\2020-11-12T11_11_40_097Z-debug.log

해결방안 찾기

구글링해서 여기를 찾았습니다.

브라우저 지정하기

webpack serve --open 'Google Chrome'

근데 크롬을 모른답니다…

[webpack-cli] Unknown argument: Chrome'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! hooks@1.0.0 start: `webpack serve --open 'Google Chrome'`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the hooks@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\W24946\AppData\Roaming\npm-cache\_logs\2020-11-12T11_17_03_025Z-debug.log

‘크롬 실행파일로 바꿔볼까?’

chrome.exe파일을 찾을 수없다고 하네요… 모를만 하지. full path를 적어봅니다.

webpack serve --open 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe\'

path에 \가 들어가니까 에러가 뜹니다.

npm ERR! code EJSONPARSE
npm ERR! file C:\Users\W24946\Desktop\hooks\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token P in JSON at position 199 while parsing near '...ck serve --open 'C:\Program Files (x86)\...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\W24946\AppData\Roaming\npm-cache\_logs\2020-11-12T11_25_27_362Z-debug.log

\를 2개 붙였는데도 안됩니다.

"start": "webpack serve --open 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'"

아래처럼 하니까 되었습니다!

Leave a Reply

Your email address will not be published.