Search code examples
node.jsreactjsnpmnpx

How to solve Node.js npm npx problem: You are using npm 2.15.12 but I'm updated?


I'm having a problem with npm. I created a React.js proyect using

npx create-react-app my_app

And it worked without any problem. Now, I started another (in another folder) also with npx create-react-app my_app, but now, there's an error that says:

"You are using npm 2.15.12 so the project will be bootstrapped with an old unsupported version of tools. Please update to npm 6 or higher for a better, fully supported experience."

And if I let the installation to complete, a bunch of errors come up: "> [email protected] postinstall C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\node_modules\react-scripts\node_modules\babel-core\node_modules\babel-register\node_modules\core-js

node -e "try{require('./postinstall')}catch(e){}"

[email protected] postinstall C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\node_modules\react-scripts\node_modules\babel-runtime\node_modules\core-js node -e "try{require('./postinstall')}catch(e){}"

[email protected] postinstall C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\node_modules\react-scripts\node_modules\babel-preset-react-app\node_modules\babel-runtime\node_modules\core-js node -e "try{require('./postinstall')}catch(e){}"

(...) a bunch more like those in different dependencies of /node_modules (...) And finally:

npm ERR! Windows_NT 10.0.19043
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Usuario\\node_modules\\npm\\bin\\npm-cli.js" "install" "--no-audit" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "[email protected]"
npm ERR! node v16.13.1
npm ERR! npm  v2.15.12
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `node -e "try{require('./postinstall')}catch(e){}"`
npm ERR! Exit status -4058
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'node -e "try{require('./postinstall')}catch(e){}"'.
npm ERR! This is most likely a problem with the core-js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node -e "try{require('./postinstall')}catch(e){}"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs core-js
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls core-js
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Usuario\Desktop\Andres\Programación\React\Entregas\PrimerEntregaFinal\my_app\npm-debug.log

Aborting installation.
  npm install --no-audit --save --save-exact --loglevel error react react-dom [email protected] has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Done.

I just don't understand what changed and why it's happening? I tried:

  1. Uninstalled and reinstalled nodejs
  2. deleted the npm_cache
  3. Using on CMD npx where npm to see where I have installed npm, showing:

    C:\Program Files\nodejs\npm.CMD

  4. There I tried:

    C:\Program Files\nodejs>npm -v 8.3.0 (so it's up to date)

What should I do? what am I doing wrong?

I'd appreciate your help.


Solution

  • If anyone still needs help with this, I solved it. I wasn't being able to find where was the outdated file that was causing so much trouble, so I ran the command npm list [email protected] (try on your CMD as admin and not as admin, also in the powershell, I tried everywhere). That command showed me:

        C:\Users\Usuario
         [email protected]
           [email protected]
    

    So at least now I knew that it was somewhere inside "Usuario", but I didn't know exactly where to look. Then I saw that I had a node_modules folder in there (when I already had it elsewhere) and deleted it. That's it, that solved my problem.

    Hope someone finds it usefull too.