react : NPM install fails
Asked Answered
T

2

7

I tried installing a package in my react app using npm, and for some reason It fails: it shows the following error:

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.

Tablet answered 9/8, 2020 at 1:36 Comment(1)
what's your package json like? did you try deleting the package-lock.json + /node_modules and then reinstalling?Winnifredwinning
I
15

TLDR

There is some dependency error with npm, so how about clear project

Answer

First of all, How about clear node_modules and package-lock.json

rm -rf ./node_modules package-lock.json

and retry install with

npm install or npm i

and what I want to say is clear package-lock.json and node_modules. If you'd like to get more information about deleting here is the link

Incandescent answered 9/8, 2020 at 1:51 Comment(2)
I tried clearing them but it ends up with that error. so I deleted the package-lock.json manually and tried npm install and it worked.Tablet
yes there is missing something (coma or similar) in the script. did delete both manually one by one: first rm -r node_modules and then rm package-lock.json.Deferent
C
1

What version of the babel (and it's sub-modules) do you use? Show rows from your package.json file (related to babel). Your issue possibly could be resolved by updating all babel-related modules

Cilka answered 9/8, 2020 at 1:52 Comment(2)
the package.json seemed to be fine, so I removed the package-lock.json and tried npm install it its solved.Tablet
It may be solved once, but occur again while you install new dependancies.Deferent

© 2022 - 2024 — McMap. All rights reserved.