5

I have followed the standard procedure (npm uninstall -g create-react-app and yarn global remove create-react-app) to remove my previous global installation of create-react-app using yarn as shown in the screenshot below. I have also checked that the following directory does not exist: /usr/local/bin/create-react-app.

However, I still get errors when using npx create-react-app myapp, saying that I am running create-react-app 4.0.0.

which create-react-app

also outputs nothing.

Hence, I am looking for a way to resolve this issue. Screenshot of terminal

Jia Cheng Sun
  • 179
  • 1
  • 2
  • 9
  • Are you sure you don’t have it installed locally in the current folder you’re in? – JBallin Dec 05 '20 at 08:51
  • 1
    I would like to close my question if I can, but I do not have enough rep. Since I have deleted this VM, I will not be able to check if the proposed solutions work. – Jia Cheng Sun Dec 06 '20 at 12:12
  • 1
    I’ve flagged it for the moderators to close the question. – JBallin Dec 06 '20 at 18:55

2 Answers2

0

Double check the NPM cache:

npm config get cache | xargs ls -tr | grep create-react-app

If it shows anything, delete it:

npm config get cache | xargs ls -tr | grep create-react-app | xargs rm -rf

If this still fails, try installing the latest stable version:

npm install -g npm@latest

Also, if it still doesn't work with npx, try with instead npm:

npm create-react-app myapp
costaparas
  • 5,047
  • 11
  • 16
  • 26
  • 1
    Appreciate the reply! Unfortunately, I have deleted this instance of my VM already and have reverted to a backup, so I would not be able to verify if this works. – Jia Cheng Sun Dec 06 '20 at 12:09
  • This is a good idea but the real issue is they were probably using node 18. I just ran into this issue and this thread. The npm cache solution didn't fix it for me but what did was switching to v16.17 of node. – Evan Erickson Oct 08 '22 at 20:49
0

I'm assuming you are using node 18. Change your node version to LTS to run into less issues. A lot of modern packages use LTS as their dependency, not node 18.

To Do: Download node LTS (Right now - 16.17.1). I would recommend doing it through homebrew and download the "nvm" package. brew install nvm

Then run nvm to make sure you get a output from the terminal. If you don't see any output, try installing nvm again through homebrew or other debugging methods.

Then go to your root (on mac cd ~) and run nvm ls-remote and that will show you a long list. You only care about LTS, items highlighted, and the very latest versions.

nvm install v16.17.1

Check you have the correct version, node -v. If it still shows the newer version run a nvm use v16.17.1 but usually they set it as your default.

With nvm you can also set profiles, switch between LTS and other versions. Sometimes you might want to use node 12 on a docker container. That is the benefit of having a tool like nvm.

Evan Erickson
  • 471
  • 5
  • 12