Module not found: Can't resolve @babel/runtime [Solved]

avatar
Borislav Hadzhiev

5 min

banner

# Table of Contents

  1. Module not found: Can't resolve @babel/runtime/helpers
  2. Module not found: Can't resolve 'babel-loader'
  3. Cannot find module '@babel/core' error

# Module not found: Can't resolve @babel/runtime/helpers

To solve the error "Module not found: Error: Can't resolve '@babel/runtime/helpers'", make sure to install the @babel/runtime package by opening your terminal and running the npm install @babel/runtime command.

module not found cant resolve babel runtime

Open your terminal in your project's root directory (where your package.json file is located) and run the following command:

shell
# ๐Ÿ‘‡๏ธ with NPM npm install @babel/runtime # ---------------------------------------------- # ๐Ÿ‘‡๏ธ with YARN yarn add @babel/runtime

npm install babel runtime

The command will add the @babel/runtime package to the dependencies of your project.

Make sure to restart your development server and your IDE if necessary. Your dev server won't pick up the changes until you stop it and re-run the npm start command.

# Delete node_modules and reinstall your dependencies

If the error is not resolved, try to delete your node_modules and package-lock.json (not package.json) files, re-run npm install and restart your IDE.

If you are on Windows, open CMD (Command Prompt) and run the following commands.

shell
# ๐Ÿ‘‡๏ธ (Windows) delete node_modules and package-lock.json rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you are on macOS or Linux, run the following commands in bash or zsh.

shell
# ๐Ÿ‘‡๏ธ (macOS/Linux) delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

Make sure to restart your IDE and dev server if the error persists. VS Code often glitches and a reboot solves things sometimes.

# Verify the @babel/runtime module is installed

If the error persists, open your package.json file and make sure it contains the @babel/runtime package in the dependencies object.

package.json
{ // ... rest "dependencies": { "@babel/runtime": "^7.21.0", }, }

The @babel/runtime module should NOT be globally installed or be in your project's devDependencies.

It should be in the dependencies object in your package.json file.

You can try to manually add the line and re-run npm install.

shell
npm install

Or install the latest version of the package:

shell
# ๐Ÿ‘‡๏ธ with NPM npm install @babel/runtime@latest # ---------------------------------------------- # ๐Ÿ‘‡๏ธ with YARN yarn add @babel/runtime

# Table of Contents

  1. Module not found: Can't resolve 'babel-loader'
  2. Cannot find module '@babel/core' error

# Module not found: Can't resolve 'babel-loader'

To solve the error "Module not found: Error: Can't resolve 'babel-loader'", make sure to install the babel-loader package by opening your terminal in your project's root directory and running the command npm install -D babel-loader and restart your development server.

Open your terminal in your project's root directory (where your package.json file is located) and run the following commands:

shell
# ๐Ÿ‘‡๏ธ with NPM npm install --save-dev babel-loader @babel/core @babel/preset-env webpack # ๐Ÿ‘‡๏ธ ONLY If you use TypeScript npm install --save-dev @types/babel__preset-env @types/babel__core @types/webpack # ---------------------------------------------- # ๐Ÿ‘‡๏ธ with YARN yarn add babel-loader @babel/core @babel/preset-env webpack --dev # ๐Ÿ‘‡๏ธ ONLY If you use TypeScript yarn add @types/babel__preset-env @types/babel__core @types/webpack --dev

npm install babel loader

The command will add the babel-loader package to the development dependencies of your project.

Refer to the "Usage" section of the official npm page for babel-loader for how to integrate it in your Webpack config.

Make sure to restart your development server and your IDE if necessary. Your dev server won't pick up the changes until you stop it and re-run the npm start command.

# Delete your node_modules and reinstall your dependencies

If the error is not resolved, try to delete your node_modules and package-lock.json (not package.json) files, re-run npm install and restart your IDE.

If you are on macOS or Linux, issue the following commands in bash or zsh.

shell
# for macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you are on Windows, issue the following commands in CMD.

cmd
# for Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

Make sure to restart your IDE and dev server if the error persists. VS Code often glitches and a reboot solves things sometimes.

# Verify the babel-loader package is installed

If the error persists, open your package.json file and make sure it contains the babel-loader package in the devDependencies object.

package.json
{ // ... rest "devDependencies": { "babel-loader": "^9.1.2", "@babel/core": "^7.21.3", "@babel/preset-env": "^7.20.2", "webpack": "^5.76.3", // ๐Ÿ‘‡๏ธ Only if you use TypeScript "@types/babel__core": "^7.20.0", "@types/babel__preset-env": "^7.9.2", "@types/webpack": "^5.28.0" } }

The babel-loader module should NOT be globally installed or be in your project's dependencies, it should be in the devDependencies object in your package.json file.

You can try to manually add the lines and re-run npm install.

shell
npm install

Or install the latest version of the package:

shell
# ๐Ÿ‘‡๏ธ with NPM npm install --save-dev babel-loader@latest @babel/core@latest @babel/preset-env@latest webpack@latest # ๐Ÿ‘‡๏ธ ONLY If you use TypeScript npm install --save-dev @types/babel__preset-env@latest @types/babel__core@latest @types/webpack@latest # ---------------------------------------- # ๐Ÿ‘‡๏ธ with YARN yarn add babel-loader@latest @babel/core@latest @babel/preset-env@latest webpack@latest --dev # ๐Ÿ‘‡๏ธ ONLY If you use TypeScript yarn add @types/babel__preset-env@latest @types/babel__core@latest @types/webpack@latest --dev

# Cannot find module '@babel/core' error

To solve the error "Cannot find module '@babel/core'", make sure to install the @babe/core package by opening your terminal in your project's root directory and running the following command: npm i -D @babel/core and restart your IDE and development server.

cannot find module babel core

Open your terminal in your project's root directory (where your package.json file is located) and run the following command:

shell
# ๐Ÿ‘‡๏ธ with NPM npm install --save-dev @babel/core # ๐Ÿ‘‡๏ธ only if you use TypeScript npm install --save-dev @types/babel__core # ------------------------------------------ # ๐Ÿ‘‡๏ธ with YARN yarn add @babel/core --dev # ๐Ÿ‘‡๏ธ only if you use TypeScript yarn add @types/babel__core --dev

npm install babel core

This will add the @babel/core package to the development dependencies of your project.

If the error is not resolved, try restarting your IDE and your development server.

# Delete your node_modules and reinstall your dependencies

If you still get the error, try to delete your node_modules and package-lock.json (not package.json) files, re-run npm install and restart your IDE.

If you are on Windows, open CMD (Command Prompt) and run the following commands.

shell
# ๐Ÿ‘‡๏ธ (Windows) delete node_modules and package-lock.json rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you are on macOS or Linux, run the following commands in bash or zsh.

shell
# ๐Ÿ‘‡๏ธ (macOS/Linux) delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

Make sure to restart your IDE and dev server if the error persists. VS Code often glitches and a reboot solves things sometimes.

# Verify you have the @babel/core module installed

If the error persists, open your package.json file and make sure it contains the @babel/core package in the devDependencies object.

package.json
{ // ... rest "devDependencies": { "@babel/core": "^7.21.3", // ๐Ÿ‘‡๏ธ only if using TypeScript "@types/babel__core": "^7.20.0" } }

You can try to manually add the line and re-run npm install.

shell
npm install

Or install the latest version of the package:

shell
# with NPM npm install --save-dev @babel/core@latest # ๐Ÿ‘‡๏ธ only if you use TypeScript npm install --save-dev @types/babel__core@latest # ------------------------------------- # ๐Ÿ‘‡๏ธ with YARN yarn add @babel/core@latest --dev # ๐Ÿ‘‡๏ธ only if you use TypeScript yarn add @types/babel__core@latest --dev

The @babel/core module should NOT be globally installed or be in your project's dependencies, it should be in the devDependencies object in your package.json file.

If the error persists, follow the instructions in my Module not found: Can't resolve 'X' error in React article.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2023 Borislav Hadzhiev