Last modified: Jun 28, 2026

Fix Cannot find module 'ora' Error

Encountering the Cannot find module 'ora' error can stop your Node.js project dead in its tracks. This common issue happens when the ora package is missing or not properly installed. Don't worry. This guide will help you fix it quickly.

The ora module provides elegant terminal spinners for Node.js command-line tools. It's a popular choice for adding visual feedback during long-running tasks. When Node.js cannot locate it, your script fails.

What Causes This Error?

The error typically appears for three main reasons. First, the ora package is not installed in your project. Second, you are running the script from the wrong directory. Third, there is a version mismatch or corrupted node_modules folder.

Let's walk through each solution step by step. These methods work for both beginners and experienced developers.

Solution 1: Install the ora Package

The most straightforward fix is to install ora using npm or yarn. Open your terminal in the project root where your package.json file lives.


# Install ora as a dependency
npm install ora

If you are using yarn, run this command instead:


# Using yarn
yarn add ora

After installation, try running your script again. The error should disappear. If it persists, move to the next solution.

Solution 2: Check Your Working Directory

Node.js looks for modules in the node_modules folder of your current directory. If you run your script from a different folder, Node.js cannot find ora.

Always ensure you are in the correct project directory. Use the pwd command on Linux/Mac or cd on Windows to verify.


# Check current directory
pwd

# Navigate to project root if needed
cd /path/to/your/project

Then run your script again. This simple step often resolves the issue for many users.

Solution 3: Reinstall Dependencies

Sometimes your node_modules folder gets corrupted. A fresh reinstall can fix this. Delete the folder and reinstall all dependencies.


# Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json

# Reinstall all dependencies
npm install

This process ensures all packages, including ora, are correctly installed. It also resolves any version conflicts.

Solution 4: Check package.json

Verify that ora is listed in your package.json file under dependencies or devDependencies. If it's missing, add it manually.


{
  "dependencies": {
    "ora": "^6.3.0"
  }
}

After adding it, run npm install to download the package. This is especially important if you cloned a project from a repository.

Solution 5: Use Global Installation (Not Recommended)

Installing ora globally might work, but it's not best practice. Global packages can cause version conflicts across projects. Use a local installation instead.


# Global installation (use with caution)
npm install -g ora

If you must use a global install, ensure your Node.js can find global modules. However, always prefer local dependency management.

Example Code with Comments

Here is a simple example of using ora correctly. Pay attention to the import and usage.


// Import the ora module
import ora from 'ora';

// Create a spinner instance
const spinner = ora('Loading data...').start();

// Simulate a long-running task
setTimeout(() => {
  // Stop spinner with success message
  spinner.succeed('Data loaded successfully!');
}, 2000);

Run this code with Node.js. It should display a spinner for 2 seconds, then show a success message.


# Expected output
✔ Data loaded successfully!

If you still get the error, double-check your import statement. For CommonJS projects, use const ora = require('ora') instead.

Additional Tips for Beginners

Always use a package.json file to manage dependencies. Initialize your project with npm init -y before installing packages. This avoids many module-related errors.

Keep your Node.js version updated. Older versions may have compatibility issues with newer modules like ora. Check your version with node -v.

If you face similar errors with other modules, our guide on Fix Node.js Error: Cannot find module can help you troubleshoot any missing package.

Common Pitfalls to Avoid

Do not manually edit node_modules. Always use npm or yarn to manage packages. Manual changes can break your entire project.

Avoid using outdated versions of ora. Check the official npm page for the latest stable release. Old versions may lack important fixes.

Remember to commit your package-lock.json file. It locks dependency versions and ensures consistent builds across environments.

Conclusion

The Cannot find module 'ora' error is easy to fix. Start by installing the package locally. Then verify your working directory and reinstall dependencies if needed. Always manage your project with a package.json file.

Follow these steps, and you will have your terminal spinner running smoothly. For more Node.js troubleshooting, explore our Fix Node.js Error: Cannot find module guide. Happy coding