简体   繁体   English

反应:NPM 安装失败

[英]react : NPM install fails

I tried installing a package in my react app using npm, and for some reason It fails: it shows the following error:我尝试使用 npm 在我的反应应用程序中安装 package,但由于某种原因它失败了:它显示以下错误:

npm ERR! Object for dependency "@babel/generator" is empty.
npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install".
npm ERR! If using a shrinkwrap, regenerate with "npm shrinkwrap".

I tried npm install to regenerate the package-lock.json but it's the same as before.我试过 npm install 来重新生成 package-lock.json 但它和以前一样。

TLDR TLDR

There is some dependency error with npm, so how about clear project npm存在一些依赖错误,那么清除项目怎么样

Answer回答

First of all, How about clear node_modules and package-lock.json首先,清除node_modulespackage-lock.json

rm -rf ./node_modules package-lock.json

and retry install with并重试安装

npm install or npm i npm installnpm i

and what I want to say is clear package-lock.json and node_modules .我想说的是清楚package-lock.jsonnode_modules If you'd like to get more information about deleting here is the link如果您想了解有关删除的更多信息,请点击此处的链接

What version of the babel (and it's sub-modules) do you use?你使用什么版本的 babel(以及它的子模块)? Show rows from your package.json file (related to babel).显示 package.json 文件(与 babel 相关)中的行。 Your issue possibly could be resolved by updating all babel-related modules您的问题可能可以通过更新所有与 babel 相关的模块来解决

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

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