Yarn: publicnpmのcredsを持つプライベートレジストリに対するスコープパッケージの `yarnadd`が失敗する

作成日 2017年01月26日  ·  3コメント  ·  ソース: yarnpkg/yarn

タイトルは少し一口です。 言い換えると、 .npmrc (またはおそらく.yarnrc )がプライベートレジストリURLとパブリックnpmに公開するための認証トークンの両方で構成されている場合、スコープパッケージのインストールが失敗します。 ここで問題となっているプラ​​イベートレジストリはArtifactoryであり、現在の理論では、YarnはArtifactoryが満足していないcreds(_inappropriately_:configは2つの異なるURL用です)と401s(credsはpublic 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

文脈で読むと、作者は「スコープ」が「認証済み」を意味すると想定しているようです。

全てのコメント3件

追加の背景として、Artifactoryインスタンスは匿名アクセスを許可するように構成されています。 クレデンシャルを提供しない場合は、好きなものを読むことができます。 資格情報を提供すると、Artifactoryはそれらの検証を試み、401ステータスを返します(この場合、ユーザーが存在しないため)。

これは問題のあるコード行だと思います: https

文脈で読むと、作者は「スコープ」が「認証済み」を意味すると想定しているようです。

先週の金曜日にまったく同じ問題が発生し、スコープ付きパッケージをローカルアーティファクトからダウンロードできるようにするには、〜/ .npmrcから認証トークンを削除する必要がありました。

このページは役に立ちましたか?
0 / 5 - 0 評価