pnpm firebase 应用程序“找不到模块‘mime’的声明文件”

问题描述 投票:0回答:1

我正在尝试在我的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 提供了自己的类型定义,因此您不需要安装它

  • 使用纱线时我没有遇到这个问题。
  • 当使用 pnpm 启动另一个节点/express 项目时,我在 .pnpm 中发现相同的依赖项,但我没有遇到问题。

深入研究 root/node_modules/.pnpmroot/pnpm-lock.yaml 导致问题的依赖关系看起来像:

[email protected] --> @types/[email protected] --> @types/[email protected] --> @types/[email protected]

我已经尝试过:

  • pnpm 商店修剪
  • 重新安装pnpm
  • root/apps/project
  • 中重新安装软件包
  • 多次清理整个项目的所有缓存文件夹、node_modules 和 .lock 文件。然后重新安装所有依赖项。

有什么想法为什么我会遇到这个问题吗?

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"
  }
typescript express google-cloud-functions monorepo pnpm
1个回答
0
投票

您可以使用以下命令删除并尝试!

pnpm 删除@types/mime

© www.soinside.com 2019 - 2024. All rights reserved.