Borislav Hadzhiev
Mon Mar 28 2022·2 min read
Photo by Maria Teneva
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.
Open your terminal in your project's root directory (where your package.json
file is located) and run the following command:
npm install --save-dev @babel/core # 👇️ only if you use TypeScript npm install --save-dev @types/babel__core
@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.
# 👇️ 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
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.
{ // ... 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
.
npm install
Or install the latest version of the package:
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.