node.js - 'node_modules/minimatch/dist/cjs/index' لا يحتوي على عضو مصدر 'IOptions'


لدي مشروع TypeScript للتشغيل على دالة Firebase.

إليك ملف tsconfig.json الخاص بي

{
  "compilerOptions": {
    "lib": ["es2017"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "dist",
    "sourceMap": true,
    "target": "es2017",
    "esModuleInterop": true,
    "strict": true
  },
  "include": ["src"],
  "exclude": ["dist", "node_modules"]
}

عندما أبني (npm run build، الذي يشغّل tsc)

لقد تلقيت الخطأ

node_modules/@types/glob/index.d.ts:29:42 - خطأ TS2694: مساحة الأسماء '"/opt/workspace/personal/kioskify-backend/functions/node_modules/minimatch/dist/cjs/index"' ليس لديها عضو مُصدّر 'IOptions'.

29 الواجهة IOptions تمتد من minimatch.IOptions {

تحرير: يحدث الخطأ في وحدات أخرى. الإخراج الكامل:

npm run build

> build
> npm run lint && tsc


> lint
> eslint --fix .

node_modules/@types/glob/index.d.ts:29:42 - error TS2694: Namespace '"/opt/workspace/personal/kioskify-backend/functions/node_modules/minimatch/dist/cjs/index"' has no exported member 'IOptions'.

29     interface IOptions extends minimatch.IOptions {
                                            ~~~~~~~~

node_modules/@types/glob/index.d.ts:75:30 - error TS2724: '"/opt/workspace/personal/kioskify-backend/functions/node_modules/minimatch/dist/cjs/index"' has no exported member named 'IMinimatch'. Did you mean 'Minimatch'?

75         minimatch: minimatch.IMinimatch;
                                ~~~~~~~~~~

node_modules/@types/rimraf/index.d.ts:33:21 - error TS2694: Namespace '"/opt/workspace/personal/kioskify-backend/functions/node_modules/glob/dist/mjs/index"' has no exported member 'IOptions'.

33         glob?: glob.IOptions | false | undefined;
                       ~~~~~~~~


Found 3 errors in 2 files.

Errors  Files
     2  node_modules/@types/glob/index.d.ts:29
     1  node_modules/@types/rimraf/index.d.ts:33

وأخطاء مشابهة أخرى، ما يمكن أن تكون؟

الإجابة رقم 1

قم بترقية rimraf و glob و minimatch إلى الأحدث. أزل حزم @types لكل الثلاثة. بعد ذلك سيعمل بشكل جيد.

كل هذه الثلاثة مكتوبة الآن بـ ts، حزم @types هي التي تسبب المشكلة.

المصدر: كتبت كل هذه الثلاثة.