์ ๋ชฉ์ด ์ข ๊ฑฐ์๊ธฐ ํฉ๋๋ค. ์ฆ, .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.
์ถ๊ฐ ๋ฐฐ๊ฒฝ์ ์ํด Artifactory ์ธ์คํด์ค๋ ์ต๋ช ์ก์ธ์ค๋ฅผ ํ์ฉํ๋๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. ์๊ฒฉ ์ฆ๋ช ์ ์ ๊ณตํ์ง ์์ผ๋ฉด ์ํ๋ ๋๋ก ์ฝ์ ์ ์์ต๋๋ค. ์๊ฒฉ ์ฆ๋ช ์ ์ ๊ณตํ๋ฉด Artifactory๋ ์๊ฒฉ ์ฆ๋ช ์ ์ ํจ์ฑ์ ๊ฒ์ฌํ๊ณ 401 ์ํ๋ฅผ ๋ฐํํฉ๋๋ค(์ด ๊ฒฝ์ฐ ์ฌ์ฉ์๊ฐ ์กด์ฌํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค).
๋๋ ์ด๊ฒ์ด ๋ฌธ์ ์ ์ฝ๋ ๋ผ์ธ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค. https://github.com/yarnpkg/yarn/blob/master/src/registries/npm-registry.js#L56 (๋ง์ง๋ง ์ ).
๋ฌธ๋งฅ์ ๋ณด๋ฉด ์ ์๊ฐ "๋ฒ์ ์ง์ "์ด "์ธ์ฆ๋จ"์ ์๋ฏธํ๋ค๊ณ ๊ฐ์ ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค.
์ง๋ ๊ธ์์ผ์ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ฌ ๋ก์ปฌ ์ํฐํฉํธ์์ ๋ฒ์ ์ง์ ํจํค์ง๋ฅผ ๋ค์ด๋ก๋ํ ์ ์๋๋ก ~/.npmrc์์ ์ธ์ฆ ํ ํฐ์ ์ ๊ฑฐํด์ผ ํ์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๋ ์ด๊ฒ์ด ๋ฌธ์ ์ ์ฝ๋ ๋ผ์ธ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค. https://github.com/yarnpkg/yarn/blob/master/src/registries/npm-registry.js#L56 (๋ง์ง๋ง ์ ).
๋ฌธ๋งฅ์ ๋ณด๋ฉด ์ ์๊ฐ "๋ฒ์ ์ง์ "์ด "์ธ์ฆ๋จ"์ ์๋ฏธํ๋ค๊ณ ๊ฐ์ ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค.