node.js - لا يحتوي node_modules/minimatch/dist/cjs/index على عضو مُصدر باسم 'IMinimatch'. هل كنت تقصد 'Minimatch'؟
لدي rimraf كمختصر تطويري (v5.0.0). عندما أحاول تشغيل برنامج نصي باستخدام rimraf، يعطي لي هذا الخطأ:
node_modules/@types/glob/index.d.ts:29:42 - error TS2694: Namespace '".../node_modules/minimatch/dist/cjs/index"' has no exported member 'IOptions'.
29 interface IOptions extends minimatch.IOptions {
~~~~~~~~
node_modules/@types/glob/index.d.ts:74:30 - error TS2724: '"...node_modules/minimatch/dist/cjs/index"' has no exported member named 'IMinimatch'. Did you mean 'Minimatch'?
74 minimatch: minimatch.IMinimatch;
~~~~~~~~~~
Found 2 errors in the same file, starting at: node_modules/@types/glob/index.d.ts:29
لقد قمت بإزالة مجلد node_modules/@types/glob يدويًا واختفت الخطأ، و rimraf يعمل بشكل ممتاز. المشكلة هي أنني لا أملك glob أو minimatch أو أنواعها كاعتماديات في مشروعي، لذلك لا أستطيع إزالة الاعتمادية لحل المشكلة.
هذه هي التبعيات التي لدي في package.json:
"devDependencies": {
"@open-wc/building-rollup": "2.0.1",
"@open-wc/eslint-config": "7.0.0",
"@open-wc/testing": "3.1.3",
"@rollup/plugin-replace": "4.0.0",
"@typescript-eslint/eslint-plugin": "5.20.0",
"@typescript-eslint/parser": "5.20.0",
"@web/dev-server": "0.1.30",
"@web/test-runner": "0.13.27",
"@web/test-runner-puppeteer": "0.10.5",
"concurrently": "7.1.0",
"deepmerge": "4.2.2",
"eslint": "8.13.0",
"eslint-config-prettier": "8.5.0",
"husky": "7.0.4",
"lint-staged": "12.4.0",
"prettier": "2.6.2",
"rimraf": "5.0.0",
"rollup": "2.70.2",
"rollup-plugin-copy": "3.4.0",
"tslib": "2.3.1",
"typescript": "4.6.3"
}
لا أعرف إذا كان السبب هو rimraf فقط، أو قد يكون برنامج آخر.
أقدّر الإجابات! :)
الإجابة رقم 1
لقد حللت مشكلة مماثلة بمجرد إجبار التجاوز لحزمة glob وminimatch. ربما ليست هذه هي الحل الصحيح، لكني رأيت العديد من الحزم المضمنة تستخدم إصدارات مختلفة من minimatch وglob لذا كانت محاولتي الأولى استخدام أحدث الحزم.
الخطوات
1- لقد أضفت في نهاية package.json الآتي
...
"overrides": {
"minimatch": "5.1.2",
"glob": "8.1.0"
},
...
2- بعد الإضافة إلى package.json، كل ما أحتاجه هو التقليم:
npm prune
اختياري: في حال لم ينجح ذلك، حاول إزالة node_modules و package-lock.json
احذف -rf node_modules; احذف package-lock.json
وتثبيت جميع الوحدات/الحزم مرة أخرى
npm تثبيت
هنا المثال الكامل إذا كنت تريد أن ترى أين تضيفه داخل ملف package.json الخاص بك:
{
"name": "foo",
"version": "0.0.0",
"dependencies": {
"express": "expressjs/express",
"mocha": "mochajs/mocha#4727d357ea",
"module": "user/repo#feature/branch"
},
"overrides": {
"minimatch": "5.1.2",
"glob": "8.1.0"
}
}
وثائق NPM
الإجابة رقم 2
إذا كان عليّ التخمين، يبدو أن إحدى الاعتمادات لديك تواجه مشكلة مع الإصدار.
سأحاول حذف ملف package.json وإعادة التثبيت.
يمكنك أيضًا قراءة المزيد عن مشكلتك المحددة هنا: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/63967
تحرير: بعد المزيد من البحث، اكتشفت أن حزم @types لهذه التبعيات المحددة قد تكون هي السبب في المشكلة. جرب إزالتها.
