💡Aha!

Yarn Berry에서 ERR_LOADER_CHAIN_INCOMPLETE 오류

Node.js의 버전을 18로 업그레이드하고 나서, Yarn Berry (Yarn v3)를 사용하는 프로젝트에서 다음과 같은 오류가 발생했다.

1node:internal/errors:484
2 ErrorCaptureStackTrace(err);
3 ^
4
5Error [ERR_LOADER_CHAIN_INCOMPLETE]: "file:///.../.pnp.loader.mjs 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
6 at new NodeError (node:internal/errors:393:5)
7 at ESMLoader.resolve (node:internal/modules/esm/loader:849:13)
8 at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
9 at async Promise.all (index 0)
10 at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
11 at async loadESM (node:internal/process/esm_loader:91:5)
12 at async handleMainPromise (node:internal/modules/run_main:65:12) {
13 code: 'ERR_LOADER_CHAIN_INCOMPLETE'
14}
15
16Node.js v18.12.0

해결법

1yarn set version canary

Yarn 버전을 canary인 v4.0.0-rc.27로 업그레이드하여 문제를 해결했다.

Yarn 최신 버전에서 테스트 중인 Experimental ESM loader와 관련하여 문제가 발생한 듯하다.

ref

2024 Dohyun Jung.
Made with ☕️.