Solve - Cannot find module '@babel/core' error

avatar

Borislav Hadzhiev

Mon Mar 28 20222 min read

banner

Photo by Maria Teneva

Solve - 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
npm install --save-dev @babel/core # 👇️ only if you use TypeScript npm install --save-dev @types/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.

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.

shell
# 👇️ delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json # 👇️ clean npm cache npm cache clean --force npm install
Make sure to restart your IDE and dev server if the error still persists. VSCode often glitches and a reboot solves things sometimes.

If you're still getting the "Cannot find module '@babel/core'" error, 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.17.8", // 👇️ only if using TypeScript "@types/babel__core": "^7.1.19", } }

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
npm install --save-dev @babel/core@latest # 👇️ only if you use TypeScript npm install --save-dev @types/babel__core@latest

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.

Use the search field on my Home Page to filter through my more than 1,000 articles.