Yarn: public npm์— ๋Œ€ํ•œ creds๊ฐ€ ์žˆ๋Š” ๊ฐœ์ธ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์— ๋Œ€ํ•œ ๋ฒ”์œ„ ์ง€์ • ํŒจํ‚ค์ง€์˜ 'yarn add'๊ฐ€ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2017๋…„ 01์›” 26์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: yarnpkg/yarn

์ œ๋ชฉ์ด ์ข€ ๊ฑฐ์‹œ๊ธฐ ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, .npmrc (๋˜๋Š” .yarnrc )๊ฐ€ _๋ชจ๋‘_ ๋น„๊ณต๊ฐœ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ URL _๋ฐ_ ๊ณต๊ฐœ npm์— ๊ฒŒ์‹œํ•˜๊ธฐ ์œ„ํ•œ ์ธ์ฆ ํ† ํฐ์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉด ๋ฒ”์œ„ ํŒจํ‚ค์ง€ ์„ค์น˜๊ฐ€ ์ค‘๋‹จ๋ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ๋ฌธ์ œ์˜ ๊ฐœ์ธ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ๋Š” Artifactory์ด๊ณ , ๊ณ„์†๋˜๋Š” ์ด๋ก ์€ Yarn์ด Creds(_๋ถ€์ ์ ˆํ•˜๊ฒŒ_: ๊ตฌ์„ฑ์€ ๋‘ ๊ฐœ์˜ ์„œ๋กœ ๋‹ค๋ฅธ URL์— ๋Œ€ํ•œ ๊ตฌ์„ฑ์ž„)์™€ 401(creds๋Š” ๊ณต์šฉ npm์šฉ์ด๋ฏ€๋กœ ์•„ํ‹ฐํŒฉํ† ๋ฆฌ ์•„๋‹˜). ๋ฒ”์œ„๊ฐ€ ์ง€์ •๋œ ํŒจํ‚ค์ง€๊ฐ€ ๋‹ค๋ฅธ ๋ฐฉ์‹์œผ๋กœ ์ž˜ ์ž‘๋™ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์™œ ๋‹ค๋ฅด๊ฒŒ ์ทจ๊ธ‰๋˜๋Š”์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ์€ ์„ค๋ช…ํ•  ๋ช‡ ๊ฐ€์ง€ ๋ช…๋ น์ž…๋‹ˆ๋‹ค.

> pwd
~

> cat .yarnrc
cat: .yarnrc: No such file or directory

> cat .npmrc
registry=<private registry URL that works fine with npm and non-scoped packages>
//registry.npmjs.org/:_authToken=<my auth token>

> yarn add @types/d3-scale --verbose
yarn add v0.19.1
info No lockfile found.
verbose Performing "GET" request to "https://yarnpkg.com/latest-version".
[1/4] ๐Ÿ”  Resolving packages...
verbose Performing "GET" request to "<correct private registry URL ...>/@types%2fd3-scale".
verbose Request "<correct private registry URL ...>/@types%2fd3-scale" finished with status code 401.
verbose Error: Couldn't find package "@types/d3-scale" on the "npm" registry.
    at MessageError (/usr/local/Cellar/yarn/0.19.1/libexec/lib/node_modules/yarn/lib/errors.js:8:5)
    at /usr/local/Cellar/yarn/0.19.1/libexec/lib/node_modules/yarn/lib/resolvers/registries/npm-resolver.js:207:15
    at next (native)
    at step (/usr/local/Cellar/yarn/0.19.1/libexec/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/Cellar/yarn/0.19.1/libexec/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
    at process._tickCallback (internal/process/next_tick.js:103:7)
error Couldn't find package "@types/d3-scale" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

> npm install @types/d3-scale
~
โ””โ”€โ”ฌ @types/[email protected] 
  โ””โ”€โ”€ @types/[email protected] 

> yarn add d3-scale          
yarn add v0.19.1
info No lockfile found.
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
success Saved 8 new dependencies.
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ””โ”€ [email protected]
โœจ  Done in 2.45s.

# edit .npmrc...

> cat .npmrc 
registry=<same registry URL>

> yarn add @types/d3-scale 
yarn add v0.19.1
warning No license field
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
โ”œโ”€ @types/[email protected]
โ””โ”€ @types/[email protected]
warning No license field
โœจ  Done in 1.50s.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

๋‚˜๋Š” ์ด๊ฒƒ์ด ๋ฌธ์ œ์˜ ์ฝ”๋“œ ๋ผ์ธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. https://github.com/yarnpkg/yarn/blob/master/src/registries/npm-registry.js#L56 (๋งˆ์ง€๋ง‰ ์ ˆ).

๋ฌธ๋งฅ์„ ๋ณด๋ฉด ์ €์ž๊ฐ€ "๋ฒ”์œ„ ์ง€์ •"์ด "์ธ์ฆ๋จ"์„ ์˜๋ฏธํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ž…๋‹ˆ๋‹ค.

๋ชจ๋“  3 ๋Œ“๊ธ€

์ถ”๊ฐ€ ๋ฐฐ๊ฒฝ์„ ์œ„ํ•ด Artifactory ์ธ์Šคํ„ด์Šค๋Š” ์ต๋ช… ์•ก์„ธ์Šค๋ฅผ ํ—ˆ์šฉํ•˜๋„๋ก ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. ์ž๊ฒฉ ์ฆ๋ช…์„ ์ œ๊ณตํ•˜์ง€ ์•Š์œผ๋ฉด ์›ํ•˜๋Š” ๋Œ€๋กœ ์ฝ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž๊ฒฉ ์ฆ๋ช…์„ ์ œ๊ณตํ•˜๋ฉด Artifactory๋Š” ์ž๊ฒฉ ์ฆ๋ช…์˜ ์œ ํšจ์„ฑ์„ ๊ฒ€์‚ฌํ•˜๊ณ  401 ์ƒํƒœ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค(์ด ๊ฒฝ์šฐ ์‚ฌ์šฉ์ž๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค).

๋‚˜๋Š” ์ด๊ฒƒ์ด ๋ฌธ์ œ์˜ ์ฝ”๋“œ ๋ผ์ธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. https://github.com/yarnpkg/yarn/blob/master/src/registries/npm-registry.js#L56 (๋งˆ์ง€๋ง‰ ์ ˆ).

๋ฌธ๋งฅ์„ ๋ณด๋ฉด ์ €์ž๊ฐ€ "๋ฒ”์œ„ ์ง€์ •"์ด "์ธ์ฆ๋จ"์„ ์˜๋ฏธํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ž…๋‹ˆ๋‹ค.

์ง€๋‚œ ๊ธˆ์š”์ผ์— ๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ ๋กœ์ปฌ ์•„ํ‹ฐํŒฉํŠธ์—์„œ ๋ฒ”์œ„ ์ง€์ • ํŒจํ‚ค์ง€๋ฅผ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋„๋ก ~/.npmrc์—์„œ ์ธ์ฆ ํ† ํฐ์„ ์ œ๊ฑฐํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰