yarn - deptno/deptno.github.io GitHub Wiki

yarn

berry κΈ°μ€€

yarn info _package_name_
yarn info _package_name_ version
yarn patch-package
yarn set version berry
yarn plugin import @yarnpkg/plugin-workspace-tools

pnp

λŒ€μΆ© zero install λͺ¨λ“œκ°€ λ˜λ©΄μ„œ package κ°€ zip 파일둜 .yarn/cache λ””λ ‰ν† λ¦¬μ•ˆμ— λ“€μ–΄κ°€κ²Œλœλ‹€. λŒ€μ‹  node_modules 디렉토리가 μ—†μ–΄μ§€λ©΄μ„œ μ—λ””ν„°μ—μ„œ 문제λ₯Ό μΌμœΌμΌ°λŠ”λ° [email protected] κΈ°μ€€, 잘 λ™μž‘

λ‹€λ₯Έ μ—λ””ν„°λŠ” μ—¬μ „νžˆ λ¬Έμ œκ°€ λ˜λŠ”λ° 이λ₯Ό sdk ν˜•νƒœλ‘œ ν•¨κ»˜ λ°°ν¬ν•˜κ³  μžˆλ‹€

  • @yarnpkg/sdks
yarn dlx @yarnpkg/sdks vscode vim
yarn dlx @yarnpkg/sdks base # neovim >= 0.6 native lsp

lnp λͺ¨λ“œμ‹œ λͺ¨λ“ˆ μž„ν¬νŠΈ(require)

node cli μ—μ„œ

λͺ¨λ“ˆ μž„ν¬νŠΈκ°€ μ•ˆλ˜μ„œ ν…ŒμŠ€νŠΈν•˜κΈ°κ°€ μ§œμ¦λ‚¬λŠ”λ° μ˜΅μ…˜ μ€˜μ„œ ν•΄λ³΄λ‹ˆ λœλ‹€

node -r .pnp.cjs
$

νŒŒμΌμ—μ„œ

yarn node [script.js]

workspace, monorepo, pnp

yarn add --force @workspace/package [package_name]
yarn set version berry
yarn init -w
yarn plugin import @yarnpkg/plugin-workspace-tools
cd packages
mkdir lib
cd lib
yarn init -y

package.json

{
  "name": "tmp",
  "packageManager": "[email protected]",
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}

packages/lib/package.json

{
  "name": "papago",
  "type": "module",
  "dependencies": {
    "node-fetch": "^3.2.0"
  }
}

typescript internal modules

λͺ¨λ…Έλ ˆν¬μ—μ„œ ν•˜λ‚˜μ˜ νŒ¨ν‚€μ§€μ—μ„œ λ‹€λ₯Έ νŒ¨ν‚€μ§€λ₯Ό μ°Έμ‘°ν•˜λ €λ©΄ μ‹€μ œλ‘œλŠ” λΉŒλ“œλ₯Ό 되게 ν•˜λŠ” 것이 μ •μ„μ΄λ‚˜ λ²ˆκ±°λ‘­λ‹€. νŒ¨ν‚€μ§€λ§Œ λΆ„λ¦¬ν•˜κ³  ν•¨κ»˜ μ»΄νŒŒμ΄λ˜λ„λ‘ ν•˜λ €λ©΄ νƒ€μž…μŠ€ν¬λ¦½νŠΈ compilerOptions 에 μΆ”κ°€ 섀정이 ν•„μš”ν•˜λ‹€

  "baseUrl": ".",
  "paths": {
    "@project/package": [
      "packages/package/src"
    ],
    "@project/package/*": [
      "packages/package/src/*"
    ]
  }

@project/package λŠ” μ°Έμ‘°ν•  νŒ¨ν‚€μ§€μ˜ package.json:name κ³Ό κ°™κ²Œν•œλ‹€

node_modules

  • 2023-02-03 μ•„λž˜ λ‚΄μš©μ€ @yarnpkg/sdks λ₯Ό 톡해 해결이 κ°€λŠ₯ν•˜λ©° webstorm 도 ν˜„μž¬ zero install 을 μ§€μ›ν•΄μ„œ μœ μš©ν•˜μ§€ μ•Šλ‹€

.yarnrc.yml

yarnPath: .yarn/releases/yarn-3.2.0.cjs
nodeLinker: node-modules

ν˜Ήμ€

yarn config set nodeLinker node-modules
  • nodeLinker: λ₯Ό 톡해 node_modules pnp μ—μ„œλ„ μ‚¬μš© κ°€λŠ₯ν•˜λ‹€. node_modules 이 μ—†μœΌλ©΄ 2022-03-14 ν˜„μž¬λ„ webstorm μ—μ„œ μ œλŒ€λ‘œ μ‚¬μš©μ΄ λΆˆκ°€λŠ₯ν•˜λ‹€.
    • 2023-02-13 ν˜„μž¬λŠ” nodeLinker 없이 μ‚¬μš© κ°€λŠ₯

ci

nohoist

{
  "workspaces": {
    "packages": [ "packages/*" ],
    "nohoist": [ "**/react-native" ]
  }
}

error

Unknown Syntax Error: Command not found; did you mean:

workspace tool 이 μžˆμ–΄μ•Όμ§€ κ°€λŠ₯

# https://yarnpkg.com/api/modules/plugin_workspace_tools.html
yarn plugin import workspace-tools
  • 2023-01-31 workspace package κ°€ prefix λ₯Ό κ°€μ§€κ²Œ 된 κ²ƒμœΌλ‘œ 보인닀
yarn plugin import @yarnpkg/plugin-workspace-tools

The remote archive doesn't match the expected checksum

➀ YN0000: β”‚ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➀ YN0000: β”” Completed in 0s 623ms
➀ YN0000: β”Œ Fetch step
➀ YN0013: β”‚ @ptomasroos/react-native-multi-slider@https://github.com/zigbang/react-native-multi-slider.git#commit=22a0d52e2edb40edb552c4e010cd629bc2e68e9c can't be found in the cache and will be fetched from GitHub
➀ YN0013: β”‚ multiple-cucumber-html-reporter@https://github.com/Seunghyum/multiple-cucumber-html-reporter.git#commit=e03908f469aa694900da40597ea31a9a0ca3d86f can't be found in the cache and will be fetched from GitHub
➀ YN0013: β”‚ @ptomasroos/react-native-multi-slider@git+https://github.com/zigbang/react-native-multi-slider.git#commit=22a0d52e2edb40edb552c4e010cd629bc2e68e9c can't be found in the cache and will be fetched from the remote r
➀ YN0013: β”‚ multiple-cucumber-html-reporter@https://github.com/Seunghyum/multiple-cucumber-html-reporter.git#commit=e03908f469aa694900da40597ea31a9a0ca3d86f can't be found in the cache and will be fetched from the remote rep
➀ YN0018: β”‚ @ptomasroos/react-native-multi-slider@git+https://github.com/zigbang/react-native-multi-slider.git#commit=22a0d52e2edb40edb552c4e010cd629bc2e68e9c: The remote archive doesn't match the expected checksum
➀ YN0018: β”‚ multiple-cucumber-html-reporter@https://github.com/Seunghyum/multiple-cucumber-html-reporter.git#commit=e03908f469aa694900da40597ea31a9a0ca3d86f: The remote archive doesn't match the expected checksum
➀ YN0000: β”” Completed in 5s 348ms
➀ YN0000: Failed with errors in 5s 976ms
$ YARN_CHECKSUM_BEHAVIOR=update yarn 
  • https://yarnpkg.com/advanced/error-codes#yn0018---cache_checksum_mismatch
    • 2023-01-06
      • μ‹€μ œλ‘œ μœ„ 방식을 ν•΄λ³΄λ‹ˆ 해결이 λ˜μ§€λ§Œ λ‹€λ₯Έ ν™˜κ²½μ—μ„œλŠ” μ—λŸ¬λ‘œ μΈμ‹ν–ˆλ‹€. 였직 λ‚˜λ§Œ λ‹€λ₯Έ 체크섬이 μƒκΈ°λŠ” μƒνƒœ
      • https://github.com/yarnpkg/berry/issues/2399
      • version v3.3.0 μ΄μƒμ—μ„œ ν•΄κ²° -> yarn 으둜 yarn.lock μ—…λ°μ΄νŠΈκ°€ λλ‚œ ν›„μ—λŠ” 버전을 λ‹€μ‹œ 내렀도 μ •μƒμ μœΌλ‘œ μž‘λ™λ¨
yarn set version 3.3.1

Error: Required unplugged package missing from disk. This may happen when switching branches without running installs (unplugged packages must be fully materialized on disk to work).

sharp λͺ¨λ“ˆμ„ μ„€μΉ˜ν•˜λ©΄μ„œ μ—λŸ¬κ°€ 났닀. yarn 을 μ•ˆν•œ 것은 μ•„λ‹ˆκ³  이미지λ₯Ό λΉŒλ“œν•˜λŠ” 컴퓨터와 runtime μ»¨ν…Œμ΄λ„ˆμ˜ 아킀텍쳐 차이가 λ°œμƒν•˜λ©΄μ„œ λͺ¨λ“ˆμ„ λͺ»μ°ΎλŠ”κ²Œ 문제 ν•΄λ‹Ή λͺ¨λ“ˆμ€ .yarn/unplugged μœ„μΉ˜μ— μ„€μΉ˜λ˜λŠ”λ° μ•„λ§ˆλ„ node-gyp λ₯Ό 톡해 λ„€μ΄ν‹°λΈŒ λΉŒλ“œκ°€ λ“€μ–΄κ°€κΈ° λ•Œλ¬ΈμΌ 수 μžˆμ„ 것 κ°™μŒ npm 의 κ²½μš°μ—λŠ” arch μ˜΅μ…˜μ„ μ§€μ›ν•˜μ§€λ§Œ yarn 은 이λ₯Ό μ§€μ›ν•˜μ§€ μ•ŠλŠ”λ° μ•„λž˜ λͺ…λ Ήμ–΄λ₯Ό ν†΅ν•΄μ„œ ν•΄κ²° μ„€μΉ˜μ‹œμ—λŠ” 기쑴에 μ„€μΉ˜λœ λͺ¨λ“ˆμ„ μ§€μš°κ³  μ„€μΉ˜ν•΄μ•Όν•œλ‹€. μ•„λ§ˆ λ©€ν‹° ν”Œλž«νΌμ„ λΉŒλ“œλ₯Ό ν•˜λ €λ©΄ 각 ν”Œλž«νΌ 별 μΈμŠ€ν†¨ 후에 .yarn/unplugged 디렉토리λ₯Ό 병합해야할 κ²ƒμœΌλ‘œ 생각

$ SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm_config_arch=x64 npm_config_platform=linux yarn add sharp

Premature close

➀ YN0001: β”‚ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at new NodeError (node:internal/errors:400:5)
    at PassThrough.onclose (node:internal/streams/end-of-stream:143:30)
    at PassThrough.emit (node:events:513:28)
    at emitCloseNT (node:internal/streams/destroy:132:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
➀ YN0000: β”” Completed in 5s 872ms
➀ YN0000: Failed with errors in 6s 5ms

브랜치 λ°”κΎΈλ‹ˆκΉŒ 해결됨, λΈŒλžœμΉ˜λ‚΄μ— λ¬Έμ œκ°€ μžˆμ—ˆλ˜ 걸둜 μ˜ˆμƒλ¨

link

⚠️ **GitHub.com Fallback** ⚠️