العنوان قليلا من الفم. بكلمات أكثر: عندما يتم تكوين .npmrc
(أو ، على الأرجح ، .yarnrc
) باستخدام _b كل من _ كلاهما _ URL التسجيل الخاص _ و_ رمز المصادقة للنشر إلى npm العامة ، تثبيت فواصل الحزم المحددة. السجل الخاص المعني هنا هو Artifactory ، والنظرية الجارية هي أن Yarn يرسل الاعتمادات (_inappily_: التكوين لعناوين URL مختلفين) ، والتي لم تكن Artifactory سعيدة بها ، و 401 (نظرًا لأن الاعتمادات مخصصة لـ 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/regatives/npm-registry.js#L56 (الفقرة الأخيرة).
عند القراءة في السياق يبدو أن المؤلف يفترض أن "النطاق" يعني ضمناً "مصدق عليه".
واجهت نفس المشكلة تمامًا يوم الجمعة الماضي ، واضطررت إلى إزالة رمز المصادقة من ~ / .npmrc لتتمكن من تنزيل الحزمة المحددة من المصنع المحلي.
التعليق الأكثر فائدة
أعتقد أن هذا هو سطر الكود المسيء: https://github.com/yarnpkg/yarn/blob/master/src/regatives/npm-registry.js#L56 (الفقرة الأخيرة).
عند القراءة في السياق يبدو أن المؤلف يفترض أن "النطاق" يعني ضمناً "مصدق عليه".