💡Aha!

Yarn Berry에서 ERR_LOADER_CHAIN_INCOMPLETE 오류

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

node:internal/errors:484
ErrorCaptureStackTrace(err);
^
Error [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.
at new NodeError (node:internal/errors:393:5)
at ESMLoader.resolve (node:internal/modules/esm/loader:849:13)
at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12) {
code: 'ERR_LOADER_CHAIN_INCOMPLETE'
}
Node.js v18.12.0

해결법

yarn set version canary

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

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

ref

2024 Dohyun Jung.
Made with ☕️.