문제점
eslint 9, pnpm 10.13, node 22 환경에서 next.js 15의 eslint 플러그인을 적용했다.
에디터 eslint 플러그인에서 다음 에러를 뱉는다:
Error: Failed to load plugin 'react-hooks' declared in ' » eslint-config-next/core-web-vitals » /Users/doda/workspace/frontend/node_modules/.pnpm/eslint-config-next@15.3.5_eslint@9.31.0_typescript@5.8.3/node_modules/eslint-config-next/index.js': Cannot find module 'eslint-plugin-react-hooks'Require stack:- /Users/doda/workspace/frontend/__placeholder__.js

왜 발생할까?
엄청 자세히 설명해주신 분이 있다. 감사합니다.
요약하면, pnpm v10부터 public-hoist-pattern 기본 값에서 eslint와 prettier가 제외됨 + eslint config가 flat config를 사용하지 않고 레거시(eslintrc) 방식대로 설정되어 있어서 발생하는 문제다.
해결법
1안) public-hoist-pattern 추가해주기
.npmrc
만들기
- 다음 내용 추가
public-hoist-pattern[]=*eslint*public-hoist-pattern[]=*prettier*
- 해결 완료!
2안) 비공식 eslint-plugin-nextjs 사용하기
이 문제를 근본적으로 해결하는 PR을 만든 분께서 비공식 포크를 npm에 올려놓았다.
공식 eslint-plugin-next 대신 이 라이브러리를 사용하면 해결될 것이다. 근데 나는 1안으로 해결했다.
관련 이슈 및 링크
https://github.com/vercel/next.js/pull/76935
https://github.com/vercel/next.js/issues/78813
태그
pnpm
•
next.js
•
eslint
반응과 댓글 시스템은 Giscus에 의해 호스팅되며, 모든 대화는 GitHub에 저장됩니다.