node.js - 如何解决错误 : Cannot find module 'express-rat

我在 express 应用程序中使用模块 express-rate-limit 来限制请求,但在运行应用程序时出现此错误:找不到模块 'express-rate-limit' 虽然我在 node_modules 中安装了这个模块 我哪里错了?

我的代码如下:

import express from "express";
import rateLimit from 'express-rate-limit';

const app = express();

app.use('/api', rateLimit({
  windowMs: 10 * 60 * 1000, // 10 mins
  max: 100,
  message: 'To many requests, please try again later!',
})); 

app.listen(3000, () => console.log('App running on port 3000'))

最佳答案

我找到了解决此错误的解决方案,只需降级到较低版本即可。

关于node.js - 如何解决错误 : Cannot find module 'express-rate-limit' in Express JS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70494625/

相关文章:

flutter - 错误 : Member not found: 'PlatformInterfac

python - 如何处理两个事件循环? Pyrogram 和 Tkinter 的

python - Spyder 5.1.5 内核挂起,5.2.1 无法与 conda 一起使用

python - "' str ' object has no attribute ' 将 slug

javascript - Firebase AppCheck 网络应用程序无法在生产模式下运行

python - 在不保留旧父类的情况下用另一个类替换父类

javascript - NextJS自动将标签替换为组件

SQL 查询 - 当我们在 where 子句中使用主键时更新/删除语句的性能

python - 如何使用正则表达式创建特定的虚拟变量?

vue.js - 从 axios 中的 response.headers 访问 Set-Cookie