Last modified: Jun 24, 2025 By Alexander Williams
Fix Error: Cannot find module 'express'
If you see the error Cannot find module 'express', don't worry. This is a common issue in Node.js. It happens when the Express module is missing.
Table Of Contents
Why does this error occur?
The error means Node.js cannot locate the Express module. This usually happens for these reasons:
- Express is not installed
- The module is installed in the wrong folder
- Node.js cannot access the module path
How to fix the error
1. Install Express
First, check if Express is installed. Run this command in your project folder:
npm list express
If Express is not listed, install it:
npm install express
This will add Express to your node_modules folder.
2. Check your package.json
Make sure Express is in your dependencies. Open package.json and look for:
"dependencies": {
"express": "^4.18.2"
}
If it's missing, run npm install express --save
to add it.
3. Verify the installation path
Sometimes modules install in the wrong place. Check your node_modules folder for Express.
If it's missing, delete node_modules and run:
npm install
4. Check your require statement
Make sure your code has the correct require statement:
const express = require('express');
Typos in the module name will cause the error.
Global vs local installation
Express should be installed locally in your project. Global installs can cause issues.
To check global modules:
npm list -g express
If you need to remove a global install:
npm uninstall -g express
Working example
Here's a simple Express app to test:
// app.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Run it with:
node app.js
If everything works, you'll see:
Server running on port 3000
Common mistakes
These mistakes often cause the error:
- Running code from wrong directory
- Using an old Node.js version
- Permission issues with node_modules
For more Node.js module errors, see our guide on Fix Node.js Error: Cannot find module.
Conclusion
The Cannot find module 'express' error is easy to fix. First install Express with npm install express
. Then check your require statement and file paths.
Most times, reinstalling the module solves the issue. If not, check your Node.js version and permissions.
Now you can get back to building your Express app without this error stopping you.