0

I'm going in circles with npx trying to start a new project. Here's what I get:

"PS C:\Users\John\Documents\WebSites\react_projects> npx create-react-app material-ui Need to install the following packages: create-react-app Ok to proceed? (y) y

"You are running create-react-app 4.0.3, which is behind the latest release (5.0.0).

"We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:

  • npm uninstall -g create-react-app
  • yarn global remove create-react-app

The latest instructions for creating a new app can be found here: https://create-react-app.dev/docs/getting-started/"

When I type npm uninstall -g create-react-app, I get "up to date, audited 1 package in 495ms. found 0 vulnerabilities."

So I try to create the app again with npx, and I get this:

"Need to install the following packages: create-react-app Ok to proceed? (y)"

So I press y, and I get the first error message again. I just go in circles. How can I fix this?

John G.
  • 29
  • 4
  • After the global uninstall, if you run `npm ls -g --depth=0`, what do you get? If create-react-app is not part of the list, do you then run `npx create-react-app SOMEAPP` with SOMEAPP with whatever your new app should be? You should see an output similar to the gif found at https://create-react-app.dev/docs/getting-started – SILENT Dec 14 '21 at 23:43
  • Okay, I ran your command, and the result was: c:\Users\John\AppData\Roaming\npm firebase-tools@9.23.0 json-server@0.17.0 npm@8.1.2 Then I ran npx create-react-app my-app-name, and I get the following: Unknown command: "create-react-app" To see a list of supported npm commands, run: npm help – John G. Dec 15 '21 at 00:10
  • Reinstall nodejs and npm – SILENT Dec 15 '21 at 01:53
  • Thanks for your help. I reinstalled/updated node to version 17.2. I ran create-ract-app myapp, and I get the same error message -- "You are running 'create-react-app' 4.0.3," blah, blah, blah. Any other ideas? – John G. Dec 15 '21 at 10:44
  • Are you using powershell? Is it version 7 (ie try $PSVersionTable ) – SILENT Dec 15 '21 at 16:28
  • Looks like I'm below version 7, but I think I've got some problems with my computer. I just updated code in an older app and ran npm run start to take a look, and I get a whole lot of error codes. I was able to install yarn and I created a new app, but now I can't get my older apps to run. – John G. Dec 15 '21 at 21:57

2 Answers2

0

Refer to official reactjs website you need to have ""Node >= 14.0.0 and npm >= 5.6"" on your machine. https://reactjs.org/docs/create-a-new-react-app.html . Also yarn create is available in Yarn 0.25+ so you might want to check these versions

Amin Arshadinia
  • 188
  • 1
  • 6
  • Thanks. My versions of Node and npm are both above those versions (16.13.0 & 8.1.2). As SILENT suggested above, I'm going to try reinstalling Node. – John G. Dec 15 '21 at 10:16
0

npm stands for node package manager. It helps to install, migrate apps by adding dependencies in package.json file. You only need to run npm i. For example in react API call npm i axios you should run and import in file in order to use axios features. Also all you need to have is package.json following dependencies and packages will be added(except node_modules folder as it comes with packages and more in size). You can use npm to start, build, eject, watch and test.

npx is a CLI tool which provide way to install and manage dependencies hosted in npm registry. It is bundled with npm since 5.2.0v. It is helpful in installing and getting started with frontend JS libraries like reactjs, angularjs, vuejs, Sveltejs or boilerplate apps.

kaych22
  • 61
  • 1
  • 5