javascript - ไม่สามารถหาไฟล์การกำหนดประเภทสำหรับ 'redux-logger' ใน tsconfig.json
ฉันกำลังทำงานในแอป React โดยใช้ TypeScript และ Redux ฉันได้อัปเดตแพ็กเกจ npm หลายตัว ซึ่งรวมถึงแพ็กเกจ typescript และตอนนี้ไฟล์ tsconfig.json (ไฟล์กำหนดค่าคอมไพเลอร์ TypeScript) กำลังแสดงข้อผิดพลาดดังต่อไปนี้:
ไม่พบไฟล์กำหนดประเภทสำหรับ 'redux-logger'
ฉันพยายามค้นหาปัญหานั้นที่นี่และในกูเกิล แต่ฉันไม่สามารถหาสิ่งที่ฉันต้องใส่ในไฟล์ tsconfig.json ได้ นี่คือเนื้อหาของไฟล์:
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": ".",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowSyntheticDefaultImports": true,
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts"
],
"include": [
"./src/**/*"
]
}
ฉันจำเป็นต้องใส่สิ่งใหม่บางอย่างใน tsconfig.json ตอนนี้หรือไม่? โครงการคอมไพล์และรันได้ดี แต่ข้อผิดพลาดนี้รบกวนฉัน
และนี่คือเวอร์ชันของแพ็กเกจ npm:
{
"name": "documentloader",
"version": "1.0.0",
"private": true,
"dependencies": {
"@material-ui/core": "^3.0.3",
"@material-ui/icons": "^3.0.1",
"react": "16.5.2",
"react-dom": "16.5.2",
"react-redux": "^5.0.7",
"react-redux-loading-bar": "^4.0.8",
"react-router-dom": "^4.3.1",
"react-scripts-ts": "latest",
"react-toastify": "^4.4.0",
"react-transition-group": "^2.5.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-saga": "^0.16.2",
"redux-thunk": "^2.3.0",
"ts-loader": "^5.2.2"
},
"devDependencies": {
"@types/classnames": "^2.2.6",
"@types/history": "^4.7.1",
"@types/jest": "^23.3.5",
"@types/node": "10.12.0",
"@types/ramda": "^0.25.39",
"@types/react": "16.4.18",
"@types/react-dom": "^16.0.9",
"@types/react-redux": "^6.0.9",
"@types/react-router-dom": "^4.3.1",
"@types/redux-logger": "^3.0.6",
"@types/webpack-env": "^1.13.6",
"awesome-typescript-loader": "^5.2.1",
"css-loader": "^1.0.0",
"csstype": "^2.5.7",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"redux-devtools-extension": "^2.13.5",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"typescript": "^3.1.3",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-middleware": "^3.4.0",
"webpack-dev-server": "^3.1.9",
"webpack-hot-middleware": "^2.24.3"
}
}
อัปเดต
เนื้อหาของโฟลเดอร์ @types/redux-logger:
คำตอบ #1
ข้อผิดพลาดนี้น่าจะหมายความว่า กลไก typeRoots พบไดเรกทอรีที่ดูเหมือนว่าจะเป็นแพ็กเกจชื่อ @types/redux-logger แต่ไดเรกทอรีนั้นไม่มีไฟล์ประกาศ หากคุณมีไดเรกทอรีว่างที่ node_modules/@types/redux-logger ลองลบมันออกดู

