Last modified: Jun 22, 2026
Fix Cannot find module 'multer' in Node.js
If you see the error "Cannot find module 'multer'" in your Node.js application, don't panic. This is a common issue for beginners and seasoned developers alike. The error usually means that the multer package is not installed or not properly linked to your project.
Multer is a middleware for handling multipart/form-data, which is primarily used for uploading files. Without it, your file upload routes will break. In this guide, we will walk through the most common causes and fixes.
For a deeper understanding of similar issues, check our guide on Fix Node.js Error: Cannot find module for general troubleshooting strategies.
What Causes the Error?
The error occurs when Node.js cannot locate the multer module in your node_modules folder. Here are the typical reasons:
- You forgot to install multer.
- You installed multer globally instead of locally.
- You are running your script from the wrong directory.
- Your
package.jsonis missing the dependency. - A corrupted
node_modulesfolder or lock file.
Step 1: Install Multer Locally
The most common fix is to install multer as a project dependency. Open your terminal in your project root and run:
npm install multer
This command downloads multer and adds it to your node_modules folder. It also adds an entry to your package.json under dependencies.
After installation, try running your application again. If the error persists, move to the next step.
Step 2: Check Your Working Directory
You must run your Node.js script from the same directory where your node_modules folder exists. If you are inside a subfolder, Node.js may not find multer.
For example, if your project structure is:
my-project/
├── node_modules/
├── src/
│ └── server.js
└── package.json
Run your script from the my-project folder, not from src:
cd my-project
node src/server.js
Step 3: Verify package.json and node_modules
Open your package.json file and check if multer appears under dependencies:
{
"dependencies": {
"multer": "^1.4.5-lts.1"
}
}
If it's missing, add it manually or reinstall. Also, ensure that the node_modules folder contains a multer subfolder. If not, delete node_modules and package-lock.json, then run npm install again.
Step 4: Reinstall All Dependencies
Sometimes the node_modules folder gets corrupted. Fix it by reinstalling everything:
rm -rf node_modules package-lock.json
npm install
This ensures a clean install of all packages, including multer.
Step 5: Check for Typos in Your Code
A simple typo in your require statement can cause this error. Make sure you write:
const multer = require('multer');
Double-check the spelling. It should be multer, not muter, multer, or multerr.
Step 6: Avoid Global Installation
Some developers install packages globally with -g flag. This is not recommended for project dependencies. Global packages are not available to your local scripts. Always install multer locally:
npm install multer --save
The --save flag (default in newer npm versions) adds it to package.json.
Example: Using Multer Correctly
Here is a simple example of a file upload route using multer. Save this as server.js:
const express = require('express');
const multer = require('multer'); // Correct import
const path = require('path');
const app = express();
const port = 3000;
// Configure storage
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, 'uploads/'); // Folder to save files
},
filename: (req, file, cb) => {
cb(null, Date.now() + path.extname(file.originalname));
}
});
const upload = multer({ storage: storage });
// POST route for single file upload
app.post('/upload', upload.single('file'), (req, res) => {
res.send('File uploaded successfully!');
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});
Before running, create an uploads folder in your project root. Then start the server:
node server.js
If you still see the error, double-check that multer is installed. For more help, refer to our article on Fix Node.js Error: Cannot find module.
Step 7: Check Node.js and npm Versions
Outdated Node.js or npm can cause module resolution issues. Check your versions:
node -v
npm -v
If they are old, update them. For Node.js, download the latest LTS from the official site. For npm, run:
npm install -g npm@latest
Step 8: Use a Package Lock File
Ensure you have a package-lock.json file. This file locks the exact versions of dependencies. If it's missing or outdated, delete it and run npm install again.
This lock file helps avoid version conflicts that can cause the "Cannot find module" error.
Conclusion
The "Cannot find module 'multer'" error is easy to fix. Start by installing multer locally with npm install multer. Then verify your working directory, check for typos, and reinstall dependencies if needed. Always use local installations for project packages.
With these steps, you can resolve the error and continue building your file upload features. If you encounter other module errors, our guide on Fix Node.js Error: Cannot find module covers many common scenarios.
Remember to keep your node_modules clean and your package.json updated. Happy coding!