[TIL]2022/07/27 npm install --force vs --legacy-peer-deps

Calvin Park·2022년 7월 27일
0

혹시 NoSQL중에서 mongoDB를 사용한적이 있나요?

mongoDB를 사용하면 저렇게 _id 값을 저절로 생성해 주고 저 값은 unique값으로 받는다.
_id가 보기도 싫고 저 값도 너무 길어서 postNumber를 주고 숫자를 auto_increment로 주고 싶고 validation에 unique값으로 설정을해놨다. (가끔씩 RDBMS인 mySQL이 편할때도 있다고 생각한다. 조인도 편하고...곧 Node.js Express를 mysql로 blog를 만들어야지)
뭐 여튼 저튼 RDBMS는 auto_increment가 있어서 아주 편하게 값을 pprimery_key로 설정하고 unique값으로 주면 됬다.
mongoDB는 auto_increment가 있다고는 하는데 내가 이해가 잘 안됬다. $inc 뭐어쩌구 있었는데 그것도 나중에 try해봐야지 하면서 더 간단하고 직관적인 because 나는 햇병아리 개발자라서... 방법을 모색중 ㅡ

https://www.npmjs.com/package/mongoose-auto-increment
npm install mongoose-auto-increment

찾았다 찾았어~!! 이거를 install할려고 뙇 쳣다

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: hanghaeboard@1.0.0
npm ERR! Found: mongoose@6.5.0
npm ERR! node_modules/mongoose
npm ERR! mongoose@"^6.4.6" from the root project
npm ERR!

요런 에러가 나왔다. 그래서 --force로 해봤다
그랬더니

npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: mongoose-auto-increment@5.0.1
npm WARN Found: mongoose@6.4.6
npm WARN node_modules/mongoose
npm WARN mongoose@"^6.4.6" from the root project

이런 에러가 나왔다. 저렇게 에러 메세지가 나오면서 protctions가 disabled가 됬다는 것이다. 그래서 뭐어쩌구 저쩌구 해서 다른 명령어가 있을까 해서 다시 찾아 봤더니 --legacy-peer-deps 가 있다고 해서

npm install mongoose-auto-increment --legacy-peer-deps

했더니 해결이 되었다. 그럼 여기서 궁금한거는 --force 와 --legacy-peer-deps 차이점이다.
--force는 강제로 한다는 것인데 경고문이 나오고 --legacy-peer-deps 는 아무 이상 없이 설치가 된것이다.
그래서 찾아봤다.
Stackoverflow
(번역하기 힘들다... 나는 영어를 잘하지만... 번역하기가 제일 힘들다. *유학한 사람특: 번역안됨 근데 이해됨. )

npm v7버전이 나왔는데 wjs ㅞㅡqjwjsdls (4-6)버전에는 Peer Dependencies가 있으면 경고는 뜨는데, 설치가 된다는 것이다. 하지만 npm 7 will block installation. npm 7버전은 막힌다는 것이다.

You have the option to retry with --force to bypass the conflict or --legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6). - in npm github blog

다시 시도할 옵션들이 있다. --foce to bypass the conflict --force로 충돌을 우회하던지 아님 --legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).--legacy-peer-deps 명령어로 peer dependencies 전체를 무시해라(이 행동은 버전 4-6과 비슷하다.)

결론: 일단 force를 하고 안되면 --legacy 해서 오류 없이 설치를 해보자.
감사합니다.

peer dependencies<- 이것도 알아보자!

profile
Personal Velog Note

0개의 댓글