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.
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.
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.
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]
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!
There is some dependency error with npm, so how about clear project
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With