Last modified: Jul 02, 2026

Fix Cannot find module @babel/core

You run your Node.js project and see an error: Cannot find module '@babel/core'. This is a common issue for beginners and experienced developers. It stops your app from running or building. Don't worry. This article will show you how to fix it step by step. We will explain why it happens and give you clear solutions.

What is the @babel/core Error?

The @babel/core module is a core part of Babel. Babel is a tool that converts modern JavaScript into older versions for better browser support. When Node.js cannot find this module, it means your project is missing a dependency. This often happens after cloning a repo, updating packages, or moving folders.

The error message looks like this:


Error: Cannot find module '@babel/core'
Require stack:
- /path/to/your/project/node_modules/.bin/babel

This error stops your build tools like Webpack, Gulp, or Jest. Let's fix it.

Why Does This Error Happen?

There are three main reasons:

  • Missing installation – You never installed @babel/core in your project.
  • Corrupted node_modules – The folder node_modules is broken or incomplete.
  • Global vs local confusion – You installed Babel globally, but your project expects a local version.

Understanding the cause helps you choose the right fix. Let's go through each solution.

Solution 1: Install @babel/core Locally

The first and most common fix is to install @babel/core as a dev dependency. Open your terminal in the project root folder. Run this command:


npm install --save-dev @babel/core

If you use Yarn, run:


yarn add --dev @babel/core

This adds the module to your package.json and installs it inside node_modules. After that, try running your app again. The error should disappear.

Solution 2: Reinstall All Dependencies

Sometimes your node_modules folder is corrupted. The best fix is to delete it and reinstall everything. Follow these steps:

  1. Delete the node_modules folder.
  2. Delete the package-lock.json file (or yarn.lock if using Yarn).
  3. Run npm install (or yarn install).

Here is the command sequence:


rm -rf node_modules package-lock.json
npm install

This ensures a fresh and clean dependency tree. It often fixes many module errors at once. For a similar issue, check our guide on Fix Node.js Error: Cannot find module.

Solution 3: Check Your package.json

Open your package.json file. Look under devDependencies or dependencies. You should see an entry like this:


"devDependencies": {
  "@babel/core": "^7.24.0"
}

If it is missing, add it manually. Then run npm install. If the entry exists but the version is old, update it to the latest version:


npm install --save-dev @babel/core@latest

Version mismatches can cause the module not to be found. Always keep your Babel packages up to date.

Solution 4: Clear npm Cache

A corrupted npm cache can cause installation problems. Clear it with this command:


npm cache clean --force

After clearing the cache, reinstall the dependencies as shown in Solution 2. This removes any broken cached files.

Solution 5: Use npx Instead of Local Install

If you only need Babel occasionally, use npx. It runs the module from the npm registry without installing it locally. Example:


npx babel src --out-dir lib

This is a quick workaround. But for stable projects, always install it locally.

Solution 6: Check Your Node.js Version

Older Node.js versions may not support the latest Babel. Check your Node version:


node --version

If it is below version 12, upgrade Node.js. Babel 7+ requires Node 12 or higher. You can download the latest version from the official website.

Solution 7: Verify the Module Path

Sometimes the error comes from a wrong require path. Make sure your code imports @babel/core correctly. Example:


// Wrong import
const babel = require('babel-core');

// Correct import
const babel = require('@babel/core');

Older Babel packages used babel-core without the @ scope. The new version uses @babel/core. If you have old code, update the import statement.

Example: Full Fix Walkthrough

Let's simulate a real scenario. You cloned a React project and got the error. Here is the complete fix:


# Step 1: Go to project folder
cd my-react-app

# Step 2: Delete node_modules and lock file
rm -rf node_modules package-lock.json

# Step 3: Clear npm cache
npm cache clean --force

# Step 4: Install dependencies fresh
npm install

# Step 5: Ensure @babel/core is present
npm install --save-dev @babel/core

# Step 6: Run your project
npm start

After these steps, the error should be gone. Your app will run smoothly.

Preventing the Error in the Future

To avoid this error again, follow these best practices:

  • Always commit your package-lock.json or yarn.lock file.
  • Use a .gitignore file to exclude node_modules from version control.
  • Run npm install every time you pull new changes.
  • Keep your Babel plugins and presets in sync with @babel/core.

These habits save you from many dependency headaches. For more help with similar errors, read our article on Fix Node.js Error: Cannot find module.

Conclusion

The Cannot find module '@babel/core' error is easy to fix. Start by installing the module locally. If that fails, reinstall all dependencies and clear the cache. Check your package.json and Node version. Always use the correct import path. With these steps, you can resolve the error quickly. Your Node.js project will run without issues. Remember to keep your dependencies updated and clean. Happy coding!