Berry
Active development trunk for Yarn
Categories
Plug’n’Play 켜기
- 리멤버 웹 서비스 좌충우돌 Yarn Berry 도입기 - DRAMA&COMPANY
- 🚀 next.js 를 yarn berry와 typescript로 시작해버리기
- (Yarn berry) pnp(Plug And Play), Zero Install을 위한 Dependency 문제 해결하기 :: 이뇽의세상
- yarn2와 함께 PnP(Plug'n'Play)를 적용해보자. (feat. Typescript)
NPM에서 최신 버전의 Yarn을 내려받고, 버전을 Berry로 설정하면 Yarn Berry를 사용할 수 있습니다.
대략 다음과 같은 콘솔 로그가 출력된다:
warning package.json: License should be a valid SPDX license expression
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.4.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.4.1.cjs
➤ YN0000: Done in 0s 388ms
이렇게 하면 몇 가지 수정사항이 생긴다: .yarnrc.yml 파일이 생성된다.
그리고 yarnPath
에 할당된 경로에 해당하는 파일이 생성된다. 이 파일은 .gitignore에 추가하면 안된다. 버전 관리 대상으로 추가하자. (확인 필요)
package.json 파일 마지막에 다음 내용이 추가된다:
{
...
"packageManager": "[email protected]"
}
패키지 관리자에 대한 내용이 존재한다.
이제, yarn install
로 패키지를 설치해 보자.
.yarnrc.yml 파일 내용이 바뀐다:
pnp 로 수정:
VCS Ignore Files
Zero-Installs을 사용할 경우:
Zero-Installs을 사용하지 않을 경우:
cache folder
Troubleshooting
YN0050: The cache-folder option has been deprecated; use rc settings instead
--cache-folder .yarn
명령행 옵션을 제거하면 된다.
Cannot find module '/home/yourname/Project/charginggraph/.yarn/releases/yarn-3.4.1.cjs'
로컬에 n을 사용해 node를 설치하고, 로컬 프로젝트용 yarn을 설치 및 실행했는데 다음과 같은 에러가 발생되었다면,
$ ./yarn
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '/home/yourname/Project/charginggraph/.yarn/releases/yarn-3.4.1.cjs'
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.12.0
.yarnrc.yml 파일을 확인해 보자.
위와 같은 경우에, 해당 경로에 yarn 실행파일이 없을 수 있다. 해당 경로를 다시 잘 확인해 봐라.
yarn install 시 YN0001: ... isn't supported by any available resolver
yarn install
시 다음과 같은 에러가 발생될 수 있다.
➤ YN0000: ┌ Resolution step
➤ YN0032: │ fsevents@npm:2.3.2: Implicit dependencies on node-gyp are discouraged
➤ YN0061: │ react-image-lightbox@npm:5.1.4 is deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
➤ YN0061: │ svgo@npm:1.3.2 is deprecated: This SVGO version is no longer supported. Upgrade to v2.x.x.
➤ YN0061: │ rollup-plugin-terser@npm:7.0.2 is deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
➤ YN0061: │ stable@npm:0.1.8 is deprecated: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
➤ YN0061: │ @npmcli/move-file@npm:2.0.1 is deprecated: This functionality has been moved to @npmcli/fs
➤ YN0061: │ sourcemap-codec@npm:1.4.8 is deprecated: Please use @jridgewell/sourcemap-codec instead
➤ YN0061: │ w3c-hr-time@npm:1.0.2 is deprecated: Use your platform's native performance.now() and performance.timeOrigin.
➤ YN0001: │ Error: @yourdomain-steel/charginggraph@npm:^1.0.0: @yourdomain-steel/charginggraph@npm:1.0.0::__archiveUrl=https%3A%2F%2Fgit.server.com%2Fapi%2Fv4%2Fprojects%2F132%2Fpackages%2Fnpm%2F%40yourdomain-steel%2Fcharginggraph%2F-%2F%40yourdomain-steel%2Fcharginggraph-1.0.0.tgz%23 isn't supported by any available resolver
at yf.getResolverByDescriptor (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:391:1647)
at yf.getCandidates (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:391:1235)
at v0.getCandidates (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:435:3323)
at yf.getCandidates (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:391:1264)
at /home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:439:7693
at of (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:390:11070)
at ge (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:439:7673)
at async Promise.allSettled (index 0)
at async $s (/home/yourname/Project/steelanalysissystem-charging-webui/.yarn/releases/yarn-3.4.1.cjs:390:10398)
➤ YN0000: └ Completed in 7s 534ms
➤ YN0000: Failed with errors in 7s 539ms
만약 에러가 발생된 패키지가 npm publish으로 배포되었다면 yarn npm publish으로 다시 배포해야 한다.
Cache path does not exist
Internal Error: Cache path does not exist.
at Rt.setup (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:426:1503)
at async Rt.find (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:426:712)
at async yu.execute (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:499:11787)
at async yu.validateAndExecute (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:345:664)
at async Gn.run (/home/runner/work/yourid-tw/yourid-tw/.yarnyarn-3.6.0.cjs:359:2057)
at async Gn.runExit (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:359:2241)
at async i (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:446:12054)
at async t (/home/runner/work/yourid-tw/yourid-tw/.yarn/releases/yarn-3.6.0.cjs:446:10283)
Error: Process completed with exit code 1.
다음과 같이 캐시 폴더를 설정하던가:
아니면 명령행에서 yarn install --immutable --immutable-cache
와 같은 식으로 실행했다면 --immutable-cache
플레그를 제거하자.