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.

Developer Hub
  • 183
  • 3
  • 13
  • what's your package json like? did you try deleting the package-lock.json + /node_modules and then reinstalling? – frozen Aug 09 '20 at 01:42

2 Answers2

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

Chris
  • 1,484
  • 1
  • 12
  • 19
Stark Jeon
  • 1,107
  • 9
  • 24
  • 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. – Developer Hub Aug 09 '20 at 10:40
  • 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`. – Giorgi Gvimradze Aug 24 '20 at 20:15
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