16

I'm trying to create a new project with the typescript template as per these instructions.

npx create-react-app app-ui --template typescript

Although it installs all the node modules it does not create the starter project nor does it use the provided template. I get this message:

A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.

I'm attempting to follow the instructions and delete the global install of the cli but that also doesn't work:

 npm uninstall -g create-react-app
 up to date in 0.037s

No matter what I do I cannot uninstall the cli. What is going on?

Edit:

I was able to get it partially working on PC.

npm remove create-react-app

then

npx create-react-app my-app [--template typescript]

I tried with brackets and although the template project is there it isn't in typescript. There's something very wrong with the cli right now.

Edit:

This post solved the issue of not being able to uninstall the cli. Hope this helps someone and please upvote the OP.

Mickers
  • 1,367
  • 1
  • 20
  • 28

13 Answers13

17

For OP:

Your brackets are out of place. For your case, the documentation docs says to use:

npx create-react-app my-app --template [template-name]  

or

npx create-react-app my-app --template typescript

For everyone else:

  1. Uninstall (I'm on Linux/Ubuntu)

    sudo npm uninstall -g create-react-app
    
  2. Then run:

    npx create-react-app my-app
    

Note: Be sure that all the folders/files were removed on the uninstall. If you're having trouble accessing a the react folders in your linux setup as I was (due to permissions), gain access and remove by:

sudo chown -R $USER /usr/bin/create-react-app

(...and then do the npx command.)

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
C-Note187
  • 585
  • 4
  • 11
  • 1
    Removing the brackets got the typescript template functional. I'm not sure why I had them there. I assume I was just trying anything I could to get things working. Thanks! – Mickers Dec 09 '19 at 14:49
11

I resolved this issue by sudo npm uninstall -g create-react-app

but this did not remove create-react-app, so I had to check in which directory it is located. In the terminal, if you type:

which create-react-app

it will give you some directory like /usr/local/bin/create-react-app Now do:

rm -rf /usr/local/bin/create-react-app

This will remove create-react-app manually. Now you can start creating react app using npx create-react-app my-app

Bishal Ghimire
  • 647
  • 7
  • 15
5

I was having the same problem. This works for me (Linux)

Step 01.

sudo npm remove create-react-app

Step 02.

sudo npm uninstall -g create-react-app

Step 03.

npx create-react-app my-app --template typescript

I hope this helps.

0

Create React Startup template

1.npx create-react-app your_app_name

2.cd your_app_name

3.npm start

0

Even if you ran npm uninstall -g create-react-app create-react-app may still be installed. You can check by running which create-react-app. If a path is returned create-react-app is still installed. You can delete the module with rm -r ${returned path}. After that running npx create-react-app app-ui --template typescript should work without errors or warnings.

nprz
  • 117
  • 4
0

I came up with 3 solutions which I applied step by step when I faced this situation.

First step: From Official manual,

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

https://create-react-app.dev/docs/getting-started

You can use these commands below:

  • npx create-react-app my-app
  • npm init react-app my-app
  • yarn create react-app my-app

Second step (If first one doesn't work):

Sometimes it may keep caches.then you can use these commands given below.

  • npm uninstall -g create-react-app
  • npm cache clean --force
  • npm cache verify
  • yarn create react-app my-app

Third step:(If these 2 won't work) first uninstall via npm uninstall -g create-react-app,then check if you still have it "installed" with which create-react-app command on your command line. If you got something like (/usr/local/bin/create-react-app) then run this rm -rf /usr/local/bin/create-react-app (folder may vary) to delete manually. Then again install it via npx/npm/yarn. NB: I succeed in the last step.

Moshiur Rahman
  • 1,534
  • 12
  • 26
0

When i executed

create-react-app hello

only generated below folder structure, with notification

"A template was not provided. This is likely because you're using an outdated version of create-react-app. Please note that global installs of create-react-app are no longer supported."

node_modules
package.json
yarn.lock

Followed below steps to resolved

// Uninstalling create-react-app package

npm uninstall -g create-react-app

After that i am ready to create new react app through "npx"

For ES6 flavour (Default it will take ES6 language)

npx create-react-app hello-world

For Typescript flavour

npx create-react-app hello-world --template typescript

Following are the folder structure after running above cmd

README.md
node_modules
package.json
public
src
yarn.lock

yarn start //Works fine

node: v10.16.0
npm: 6.10.2
asishkhuntia
  • 417
  • 1
  • 4
  • 7
0

My solution ended up being a little different than yours so I will add it here just in case someone has a similar issue. Apparently I installed create-react-app globally with yarn which I could see when I ran which create-react-app which resulted in a path like .../.config/yarn/global/node_modules/.bin/create-react-app. Running yarn global remove create-react-app removed this package and then I was able to run npx create-react-app app --template typescript successfully.

thefinnomenon
  • 1,223
  • 9
  • 14
0
  1. Install create-react-app

In the beginning, we have to install create-react-app tool. It’s a tool provided by React.js creators, which allows installing ready to use React.js application, with all needed dependencies. To install the tool, we have to use the following command in the command line:

npm install -g create-react-app
  1. Create the application

Now, it’s super easy to create our first application using the create-react-app tool. We can do it with a single command in our command line. First, navigate to the folder where you want to have your application through the command line, and then run the following command, where reactapp is the name of our application:

npx create-react-app reactapp

You can feel free to set a different name for your application. If the process finished successful, you should have your folder with the app ready! Let’s start the application now!

  1. Start the application

Let’s start our reactapp with the following commands:

cd reactapp
npm start

The first command is used to enter the folder of our application, and the second one starts our app. By default, the application is open at localhost:3000, but we can change the port in the settings.

Link: https://dev.to/duomly/how-to-create-the-react-app-in-5-minutes-1bmb

Hpe this helps!

Aremu Ibrahim
  • 69
  • 1
  • 5
0

For Windows users, follow two steps

npm uninstall -g create-react-app

Then

npx create-react-app jamming

keep updating your node and npm, latest stable version

Mamunur Rashid
  • 1,095
  • 17
  • 28
0
  1. Uninstall create-react-app using command: sudo npm uninstall -g create-react-app

Since npm is not supporting global use of npm modules.

  1. install create-react-app boiler-plate as usual using command: npx create-react-app my-app

it works!!

0

I faced the same problem using Command Prompt in Windows, but then I tried the following steps on Powershell it worked. If still it is not working then Run Powershell as Administrator.

npx create-react-app my-app
cd my-app
npm start
-1

I was having the same problem. I tried this npm install -g create-react-app
Then do the create-react-app app-name It worked out for me.

Misterjoe
  • 128
  • 2
  • 10
  • Yes, but does that solve the template error? I'm now on a windows machine (was on a mac earlier) and it's doing the same thing... Empty project and typescript wasn't included. – Mickers Dec 06 '19 at 23:27