npm install 실패 시 플래그 선택
# 1. Node 버전 불일치 (engines 필드) — npm 은 기본이 경고(EBADENGINE)뿐
# 막혔다면 engine-strict 가 켜진 것. --ignore-engines 는 yarn 플래그라 npm 은 무시한다
npm install --engine-strict=false
# 2. peer dependencies 충돌 (가장 흔함)
npm install --legacy-peer-deps
# 3. 마지막 수단 (권장 안함)
npm install --force
--legacy-peer-deps가 필요한 상황
{
"react": "^18.2.0",
// 라이브러리가 아직 React 18 공식 지원 안 하지만 실제로는 동작함.
"react-beautiful-dnd": "^13.1.1" // peer: react@^16.8 || ^17
}
# 프로젝트 전체 적용
echo "legacy-peer-deps=true" > .npmrc
- package.json engines - npm: “Unless the user has set the
engine-strictconfig flag, this field is advisory only and will only produce warnings when your package is installed as a dependency.” - legacy-peer-deps - npm: “Causes npm to completely ignore
peerDependencieswhen building a package tree, as in npm versions 3 through 6.”