Last modified: Jun 24, 2026
Fix Cannot find module 'bull' Error
Seeing the error "Cannot find module 'bull'" is a common issue when working with job queues in Node.js. This error stops your script from running. It usually means Node.js cannot locate the Bull package in your project.
Don't worry. This is easy to fix. In this guide, we will cover the causes and provide clear solutions. You will learn how to install Bull correctly and avoid this error in the future.
What Does This Error Mean?
Node.js uses modules to organize code. When you write require('bull'), Node looks for the Bull package in the node_modules folder. If it is missing, you get the error:
Error: Cannot find module 'bull'
Require stack:
- /home/user/project/app.js
This error is simple. The Bull package is not installed. But there are a few reasons why this happens.
Common Causes
- Bull not installed – You forgot to run
npm install bull. - Wrong directory – You are running the script from a folder without Bull.
- Global vs local install – Bull is installed globally but your project expects it locally.
- Package.json issues – The dependency is missing from
package.json. - Version mismatch – An incompatible version of Bull is installed.
Step-by-Step Fixes
1. Install Bull Locally
The most common fix is to install Bull in your project folder. Open your terminal and run:
npm install bull
This command adds Bull to your node_modules folder. It also updates package.json. After installation, try running your script again.
2. Check Your Current Directory
Make sure you are in the correct folder. The node_modules folder must be in the same directory as your script. Use pwd (Linux/Mac) or cd (Windows) to verify.
# Check current directory
pwd
# Output: /home/user/project
# List files
ls
# Output: app.js node_modules package.json
If you are in the wrong folder, navigate to your project root and install Bull there.
3. Remove and Reinstall Bull
Sometimes the installation is corrupted. Delete the Bull folder and reinstall it.
# Remove Bull
npm uninstall bull
# Clear npm cache (optional)
npm cache clean --force
# Install again
npm install bull
This ensures you get a fresh copy of the package.
4. Check Your package.json
Open your package.json file. Look for Bull in the dependencies section. If it is missing, add it manually or run npm install bull --save.
Example of a correct package.json snippet:
{
"dependencies": {
"bull": "^4.12.0"
}
}
If you are working on a team project, run npm install to install all dependencies from package.json. This will install Bull if it is listed.
5. Avoid Global Install
Installing Bull globally (npm install -g bull) is not recommended. Node.js require looks in local node_modules first. A global install will not fix the error. Always install Bull locally in your project.
6. Use the Correct Version
Bull requires Node.js version 12 or higher. Check your Node version with node -v. If it is too old, upgrade Node.js. Also, ensure you are using a stable Bull version. The latest version is usually best.
# Check Node version
node -v
# Output: v18.16.0
Example Code: Using Bull Correctly
Here is a simple example of a Bull queue. This code will work after you install Bull.
// app.js
const Queue = require('bull'); // Require the Bull module
// Create a new queue
const emailQueue = new Queue('email', {
redis: { host: '127.0.0.1', port: 6379 }
});
// Add a job to the queue
emailQueue.add({ to: '[email protected]', subject: 'Hello' });
// Process the queue
emailQueue.process(async (job) => {
console.log('Sending email to:', job.data.to);
// Simulate email sending
return Promise.resolve();
});
console.log('Queue is running...');
If you run this code without installing Bull, you will get the error. After installation, it works perfectly.
Output After Fixing the Error
Once you install Bull correctly, the script runs without errors. The output looks like this:
$ node app.js
Queue is running...
The queue is ready to process jobs. No more "Cannot find module" errors.
Additional Tips
- Always run
npm installafter cloning a project to install all dependencies. - Use a
.gitignorefile to excludenode_modulesfrom version control. - If you are using a monorepo, ensure Bull is installed in the correct workspace.
- For more help, see our guide on Fix Node.js Error: Cannot find module for general troubleshooting.
Conclusion
The error "Cannot find module 'bull'" is easy to fix. The main solution is to install Bull locally in your project using npm install bull. Always check your current directory and package.json. Avoid global installations. With these steps, you can get your job queue running in minutes.
Remember to keep your Node.js version updated. For similar module errors, refer to our Fix Node.js Error: Cannot find module guide. Happy coding!