node.js - 找不到模块 'bson' 的声明文件

我执行了 rm -rf node_modules && npm cache verify && npm install && npm run start 现在我的控制台正在提示

node_modules/@types/mongodb/index.d.ts:46:78 - error TS7016: Could not find a declaration file for module 'bson'. '/Users/microurb/Projects/backend/node_modules/bson/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/bson if it exists or add a new declaration (.d.ts) file containing declare module 'bson';

46 import { Binary, Decimal128, Double, Int32, Long, ObjectId, Timestamp } from "bson";

我之前完全没有报错,怎么运行上面就报错了?

我尝试运行 npm i --save-dev @types/bson,但这并没有解决问题。

最佳答案

通过安装 bson 来解决这个问题

npm i --save-dev bson

由于某种原因,它似乎没有包含在 mongo dep 中

关于node.js - 找不到模块 'bson' 的声明文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69353924/

相关文章:

javascript - 无法从 'localStorage' 读取 'Window' 属性 : A

node.js - SassError : Can't find stylesheet to imp

next.js - 如何在 Next.js 中排除单个路由中的尾部斜线?

html - 在新标签页中打开 PDF - Blazor

google-cloud-platform - 将 PHP crypt MD5 密码导入 Googl

java - ClassLoader不加载内部类

python - 在 Python@3.10 上安装 cytoolz 时出现问题

html - 使用 CSS 将文本颜色设置为红色背景上的白色和白色背景上的黑色文本颜色

python - 如何删除 Pandas 中包含特定字符串的任何行?

swiftui - 如何在 iOS 15 中使用 SwiftUI 在特定 View 中隐藏 TabB