40

I am trying to create a new project using create-react-app using the command given on the docs i.e npx create-react-app my-app but it doesn't contain folders like public src and script.

4
  • Are you getting any error on running the above command? Commented Dec 10, 2019 at 4:04
  • 2
    @OsamaAftab no. package.json and node_modules are files and folder available. Commented Dec 10, 2019 at 4:09
  • Are you able to create the folders manually to check whether any permissions are causing the issue . Commented Dec 10, 2019 at 4:14
  • @User965207 yeah I can create folders. Commented Dec 10, 2019 at 4:19

15 Answers 15

88

Try with these steps :

  1. npm rm -g create-react-app
  2. npm install -g create-react-app
  3. npx create-react-app my-app

Source

2
12

I tried all the suggestion stated above but none works for me. This suggestion at 8097 works for me. Basically, I just run npx create-react-app@latest your-project-name

0
6

For those who keep trying and still doesn't work, you might have the same problem as me.

Because the global installs of create-react-app are no longer supported you might have it installed on your machine, thus have the old version running whenever you try to npx create-react-app. There are 2 very easy steps: remove create-react-app, then run the npx command.

It will look like this:

  1. sudo npm rm -g create-react-app (sudo is needed on macs to grant you permission, it will ask for your password, type it in and hit enter)
  2. npx create-react-app my-app

Should solve your problem there

3

Still didn't got to know the issue. But i tried :-

npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app

This also didn't worked for me. So I uninstalled node and installed it again. It worked for me

3

had the same issue on my mac. The correct way is if you've previously installed create-react-app globally via npm install -g create-react-app, you have to uninstall the package using npm uninstall -g create-react-app in order npx to uses the latest version.

Tips: Try npx create-react-app --info to check if npmGlobalPackages includes create-react-app. If cra is included then try the below command which create-react-app and rm -rf the outputted path.

Last but not least, force npx to use latest:

npx create-react-app@latest your-project-name

3

If someone's terminal get stuck and the initialization does not completes, just open the resource monitor and resume the cmd ,

1.window+R key- type 'resmon'

2.Locate the cmd process ,right click and resume it, initialization will be complete.

1

You can uninstall a globally installed package with this: npm uninstall -g create-react-app

1

Install Npm version of

14.18.2

Install Below Link: https://nodejs.org/dist/v14.18.2/win-x64/node.exe

2
  • 1
    This is helpful Commented Jan 4, 2022 at 4:30
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Commented Jan 9, 2022 at 6:49
0

It is not working for me on windows machine. It worked when I ran below commands from git bash:

npm install -g create-react-app
npx create-react-app my-app
0
0

Follow the following steps and that should solve your problem.

  1. sudo npm rm -g create-react-app (Do not skip sudo if you are a macOS user).

  2. npx create-react-app my-app (npm 5.2+ and higher) or npm init react-app my-app or yarn create react-app my-app (if you use yarn)

0

I had the same problem, this how I solved it.

When I try to run npm rm -g create-react-app, it shows an error.

So I went to the node modules directory (for Mac /usr/local/lib/node_modules) and delete create-react-app directory and reinstall create-react-app using npx create-react-app my-app.

0

For Windows users who are facing this issue:

  1. Open Task Manager and check if the Windows Command Processor process is set to Suspended.

  2. If it is set to Suspended, open Resource Monitor and click on the CPU tab.

  3. From within the CPU tab, locate and right-click on cmd.exe and and select Resume Process.

Click the source link below for a more detailed explanation (including screenshots).

Source: Github Issues

0

I solved it using following commands

  • npm uninstall -g create-react-app
  • yarn global add create-react-app
2
  • Could you add a couple of sentences to explain your code? Commented Aug 18, 2020 at 2:08
  • follow the above steps Commented Aug 18, 2020 at 2:51
0

In my case, i tried installing with yarn but don't downloaded all files

So I tried this

npm install --global yarn
npm uninstall -g create-react-app
npm install -g create-react-app

npx create-react-app my-app-youtube --use-npm

And it worked, with npm, i downloaded all template :D

0

Ok ok... If you are still not getting any solution

  1. Go to other Folders of your computer(like documents, Downloads) and then Create a folder for your app and Open it with VsCode(preferable)

  2. On the Terminal ( Or Powershell which is also avaliable in VsCode)

    1st Command: npm uninstall -g create-react-app

    2nd Command: npx create-react-app

Hope It Helps :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.