npm cli flag: ` force` and ` legacy peer deps` - TEAM-ARK/inflearn-clone-front GitHub Wiki

inflearn์˜ drag and drop์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ๊ฐ€์žฅ ๋น„์Šทํ•œ sortablejs ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ์œ„ํ•ด ์„ค์น˜ํ•˜๋ ค๋Š” ์ค‘ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. ๋‚ด๊ฐ€ ์„ค์น˜ํ•œ CRA์—์„œ ์ž๋™์œผ๋กœ ์„ค์น˜๋œ react์˜ ๋ฒ„์ „์€ 17.0.2์ธ๋ฐ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„  16.9.0์„ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๊ฒƒ ๊ฐ™๋‹ค ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ ๋ฆฌ์•กํŠธ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์„๋ฆฌ๋Š” ์—†๊ณ  ์•„๋งˆ dependency๋กœ 16.9.0 ์ด์ƒ์„ ํ•„์š”๋กœ ํ•œ๋‹ค๋Š” ๊ฒƒ ๊ฐ™์€๋ฐ 17.0.2๋ฉด ๊ทธ ์ด์ƒ์ธ๋ฐ ์™œ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋Š”์ง€๋Š” ์ž˜ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ์–ด์จŒ๋“  ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

ํ„ฐ๋ฏธ๋„ ์—๋Ÿฌ ๋ฉ”์„ธ์ง€์—์„  npm install ํ• ๋•Œ --force ๋˜๋Š” --legacy-peer-deps๋ฅผ ๋ถ™์—ฌ์„œ ํ•ด๊ฒฐ์„ ํ•˜๋ผ๊ณ  ํ–ˆ๋Š”๋ฐ ์ด ๋‘˜์˜ ์ฐจ์ด๋ฅผ ๋ชฐ๋ผ์„œ ์ด๋ฒˆ์— ์•Œ์•„๋ณด๊ณ ์ž ํ•œ๋‹ค.

npm v7์—์„œ ๋‹ฌ๋ผ์ง„ ์ 

2021๋…„ 2์›” npm 7๋ฒ„์ „์ด ๋‚˜์™”๋‹ค.

Automatically installing peer dependencies is an exciting new feature introduced in npm 7. In previous versions of npm (4-6), peer dependencies conflicts presented a warning that versions were not compatible, but would still install dependencies without an error. npm 7 will block installations if an upstream dependency conflict is present that cannot be automatically resolved. - in npm github blog

์•„.. ์ด๊ฒŒ npm v7๋ถ€ํ„ด peer dependencies๊ฐ€ ์ž๋™์œผ๋กœ ์„ค์น˜๊ฐ€ ๋˜๋Š”๋ฐ ์ด๋ฏธ react๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์œผ๋‹ˆ๊นŒ ์—๋Ÿฌ๊ฐ€ ๋œจ๋Š”๊ฑฐ๊ตฌ๋‚˜ ์–ด์ฉ์ง€ ๋ฆฌ์•กํŠธ๋ฅผ ์™œ react-sortable js์—์„œ ์„ค์น˜๋ฅผ ํ•˜๋ ค๊ณ  ํ•˜๋Š”๊ฑด๊ฐ€ ์‹ถ์—ˆ๋Š”๋ฐ ์ด๊ฒƒ ๋•Œ๋ฌธ์ด์—ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  npm v7๋ถ€ํ„ด peer dependencies์˜ ๋ฒ„์ „์ด ๋‹ฌ๋ผ์„œ ์ถฉ๋Œ์ด ์žˆ์„ ๊ฒฝ์šฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด์„œ ์„ค์น˜๊ฐ€ ๋˜์ง€ ์•Š๋Š”๋‹ค.

  • --legacy-peer-deps: ignore all peerDependencies when installing, in the style of npm version 4 through version 6.

    • ์„ค์น˜ ์‹œ ๋ชจ๋“  peerDependencies๋ฅผ ๋ฌด์‹œํ•œ๋‹ค. npm4~6 ๋ฒ„์ „ ์ฒ˜๋Ÿผ
  • --strict-peer-deps: fail and abort the install process for any conflicting peerDependencies when encountered. By default, npm will only crash for peerDependencies conflicts caused by the direct dependencies of the root project.

    • peerDependencies๋ฅผ ์ถฉ๋Œ์ด ์ƒ๊ธฐ๋ฉด ์„ค์น˜๊ฐ€ ์ค‘๋‹จ๋œ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ npm์€ ๋ฃจํŠธ ํ”„๋กœ์ ํŠธ์˜ ์ง์ ‘์ ์ธ ์ข…์†์„ฑ์œผ๋กœ ์ธํ•œ peerDependencies ์ถฉ๋Œ์— ๋Œ€ํ•ด์„œ๋งŒ ์ถฉ๋Œํ•ฉ๋‹ˆ๋‹ค.

๊ฒฐ๋ก 

--force๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ถฉ๋Œํ•˜๋Š” peerDependencies๊ฐ€ ๋ฃจํŠธ ํ”„๋กœ์ ํŠธ์— ์„ค์น˜๋˜๋„๋ก ํ—ˆ์šฉ --legacy-peer-deps๋Š” npm v7์—์„œ ์ œ๊ณตํ•˜๋Š” peerDependencies๊ฐ€ ์ž๋™์œผ๋กœ ์„ค์น˜๋˜๋Š” ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ --legacy-peer-deps๋ณด๋‹จ --force๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ๋‚ซ๋‹ค๋Š” ์˜๊ฒฌ์ด ๋” ๋งŽ๋‹ค.

์ฐธ๊ณ 

๊ฐœ์ธ๋ธ”๋กœ๊ทธ ์›๋ฌธ