기술
[yarn berry + husky] chalk 관련 에러 해결
기먕로기
2023. 3. 10. 13:50
상황
yarn berry가 적용된 프로젝트에 husky를 통한 pre-commit lint를 적용하려고 하다 에러가 발생하였다.
Error: chalk tried to access #ansi-styles, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
위와 같은 에러가 발생하였다
해결
.yarnrc.yml에 위 내용을 추가하면 해결된다.
나 같은 경우는 구체적인 버전을 표기하지는 않았다.
...
packageExtensions:
chalk@*:
dependencies:
"#ansi-styles": npm:ansi-styles@*
"#supports-color": npm:supports-color@*
위 내용을 추가한 후 yarn에 적용시킨다.
$ yarn
이후 잘 작동하는 것을 확인할 수 있다.