'cannot find module '@babel/generator' but it installed

i have " cannot find module '@babel/generator' " error while trying generate signed apk. But i installed this package using yarn add, this is part of my package.json:

 "dependencies": {
    "@babel/cli": "^7.17.6",
    "@babel/generator": "^7.17.9",
    "@babel/plugin-transform-async-to-generator": "^7.16.8",

and my package lock json:

  "dependencies": {
    "@ampproject/remapping": "^2.1.0",
    "@babel/code-frame": "^7.16.7",
    "@babel/generator": "^7.17.9",

and many match when i use ctrl+f in package.lock.json and search babel/generator



Solution 1:[1]

I received the same error when i was trying to install the dependencies of my project.

Solution:

  • Delete the node_modules folder of the project
  • Remove the yarn.lock or package.lock file from your project
  • Install the dependencies again, by using yarn or npm install command.

The above steps fixed my error with the @babel/generator.

Solution 2:[2]

Simply delete the node_modules folder and re-install all the packages by running npm install or yarn install.

If the error persists, simply install the @babel/generator package to your project or globally.

Check out the package and installation guide here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ashfaq nisar
Solution 2