ค้นหาเว็บไซต์

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 กำลังเป็นสาเหตุของปัญหา

ที่มา: ฉันเขียนทั้งสามอันนี้

บทความที่เกี่ยวข้อง