Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 410
Developer Hub Avatar asked Aug 09 '20 01:08

Developer Hub


People also ask

What to do when NPM fails to install a package?

Check npm's proxy configuration. Check that it's not a problem with a package you're trying to install (e.g. invalid package.json). Many ENOENT / ENOTEMPTY errors in output. npm is written to use resources efficiently on install, and part of this is that it tries to do as many things concurrently as is practical.

How to fix NPM create-react-app My-App error?

Then you need to run this command in your terminal: npm cache clean –force Now, You have to create a new react project using npx by this command: npx create-react-app my-app And now, your error will be gone. You can also Install create-react-app globally.

Is the NPM bug still there?

Update May 2021 - The NPM bug is still there, the above-linked PR failed to fix it, they've opened a new issue npm/cli#3171 so we still need to keeping using --force (or, switch to Yarn). Sorry, something went wrong. npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! Found: [email protected]

How do I resolve the upstream dependency conflict with npm err?

Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See /Users/gergo/.npm/eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR!


2 Answers

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

like image 59
Stark Jeon Avatar answered Sep 18 '22 18:09

Stark Jeon


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

like image 21
Alexander Radyushin Avatar answered Sep 21 '22 18:09

Alexander Radyushin