简体   繁体   English

找不到模块“@babel/generator”,但它已安装

[英]cannot find module '@babel/generator' but it installed

i have " cannot find module '@babel/generator' " error while trying generate signed apk.我在尝试生成签名 apk 时出现“找不到模块 '@babel/generator'”错误。 But i installed this package using yarn add, this is part of my package.json:但是我使用 yarn add 安装了这个 package,这是我的 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:和我的 package 锁 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当我在 package.lock.json 中使用 ctrl+f 并搜索 babel/generator 时,许多匹配项

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删除项目的node_modules文件夹
  • Remove the yarn.lock or package.lock file from your project从项目中删除yarn.lockpackage.lock文件
  • Install the dependencies again, by using yarn or npm install command.使用yarnnpm install命令再次安装依赖项。

The above steps fixed my error with the @babel/generator.上述步骤用@babel/generator 修复了我的错误。

Simply delete the node_modules folder and re-install all the packages by running npm install or yarn install .只需删除node_modules文件夹并通过运行npm installyarn install重新安装所有包。

If the error persists, simply install the @babel/generator package to your project or globally.如果错误仍然存在,只需将@babel/generator package 安装到您的项目或全局。

Check out the package and installation guide here此处查看 package 和安装指南

in my case it solved by this command $ yarn install --check-files在我的情况下,它通过这个命令解决了 $ yarn install --check-files

and then restart the dev server Verifies that already installed files in node_modules did not get removed Good luck然后重新启动开发服务器验证 node_modules 中已安装的文件没有被删除祝你好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM