我正在尝试在我的turborepo monorepo 中从yarn 切换到pnpm。 运行 lint 或构建时出现此错误:
../../node_modules/.pnpm/@[email protected]/node_modules/@types/serve-static/index.d.ts:4:20
- error TS7016: Could not find a declaration file for module 'mime'.
'/path-to-project/node_modules/.pnpm/[email protected]/node_modules/mime/index.js' implicitly has an 'any' type.
看起来我的依赖关系图 @types/mime 的某些级别已安装,但它已被弃用且多余,如 npm 页面所述: 这是一个存根类型定义。 mime 提供了自己的类型定义,因此您不需要安装它
深入研究 root/node_modules/.pnpm 和 root/pnpm-lock.yaml 导致问题的依赖关系看起来像:
[email protected] --> @types/[email protected] --> @types/[email protected] --> @types/[email protected]
我已经尝试过:
有什么想法为什么我会遇到这个问题吗?
pnpm v8.15.5
root/apps/project/tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compil
eOnSave”:true, “包括”: [ “源” ] }
root/apps/project/package.json
"dependencies": {
"firebase-admin": "^12.0.0",
"firebase-functions": "^4.8.2"
},
"devDependencies": {
"event-dee-types": "workspace:*",
"firebase-functions-test": "^3.1.1",
"typescript": "^4.9.0"
},
root/package.json
"dependencies": {
"daisyui": "4.6.0",
"dotenv-cli": "^7.2.1",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^20.10.4",
"@types/react": "^18.0.22",
"@types/react-dom": "^18.0.7",
"autoprefixer": "^10.4.14",
"eslint": "^7.32.0",
"eslint-config-custom": "workspace:*",
"postcss": "^8.4.21",
"sass": "^1.62.0",
"tailwindcss": "^3.3.1",
"turbo": "latest",
"typescript": "^5.0.4"
}
您可以使用以下命令删除并尝试!
pnpm 删除@types/mime