Home > Software design >  How to solve the error: Cannot find module 'express-rate-limit' in Express JS?
How to solve the error: Cannot find module 'express-rate-limit' in Express JS?

Time:12-28

I am using module express-rate-limit in express app to limit requests but i got this error when run app: Cannot find module 'express-rate-limit' although i was installed this module in node_modules What i am wrong?

My code below:

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'))

image capture for this error

CodePudding user response:

remove node_module and reinstall

CodePudding user response:

I was found the solution to solve this error, just downgrade to lower version and it works.

  • Related