How to fix the Cannot find module '@babel/core' error
In this tutorial, we are going to learn about how to fix the Cannot find module ‘@babel/core’ error.
When we run a project using npm start, sometimes we see the following error in our terminal.
ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@babel/core'
It occurs due to the package name is changed from babel-core
to @babel/core
To fix the error, we can install the @babel/core
module by running the following command.
npm i -D @babel/core
If your still facing the issue even after installing the @babel/core
module follow the below steps to fix it.
- First, remove the
node_modules
folder,package-lock.json
file present inside your project directory by using the below command.
rm-rf node_modules
rm-rf package-lock.json
or you can remove it manually by right-clicking on it and select the delete
option.
- Clear the npm cache.
npm clean cache --force
- Re-install the node modules again by running the
npm install
command.