Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create-React-App does not create starter template

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.

like image 492
Mickers Avatar asked Dec 06 '19 20:12

Mickers


People also ask

Why React app is not creating?

If you really need create-react-app , you might need to reinstall Node and reconfigure your dependencies to ensure you have a fresh start with Node, npm, npx, and the like.

Is create React app still supported?

Create-react-app no longer supported #12314 Please note that global installs of create-react-app are no longer supported. You can fix this by running npm uninstall -g create-react-app before using create-react-app again.

Does create React app create a repository?

Note: A new Git repository is created whenever you make a new project with Create React App. You can start saving changes to your app right away using git add . and git commit -m "your commit message" .

How do I start a react app?

You simply run one command and Create React App sets up the tools you need to start your React project. Less to Learn. You can just focus on React alone and don't have to worry about webpack, babel, and other such build dependencies. Only one build dependency react-scripts.

Why is create react-app My-App not working?

then running yarn create react-app my-app or npx create-react-app my-app may still gives the error, 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.

Can I use custom templates with create-react-app?

With the new release of create-react-app, you can create a new app using custom templates. Two templates available so far: More details of the latest changes in create-react-app: Show activity on this post. I too had the same problem. When I trid the npm init react-app my-app command returned the same message A template was not provided.

What is CRA (create react app)?

What is CRA? Create React App is a toolchain built and maintained by developers at Facebook for bootstrapping React applications. You simply run one command and Create React App sets up the tools you need to start your React project. Less to Learn.


3 Answers

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.)

like image 167
C-Note187 Avatar answered Oct 24 '22 01:10

C-Note187


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

like image 11
Bishal Ghimire Avatar answered Oct 24 '22 02:10

Bishal Ghimire


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.

like image 5
Lakshan Hettiarachchi Avatar answered Oct 24 '22 03:10

Lakshan Hettiarachchi