2

After running npm init react-app new-app --template typescript it simply creates a javascript template project, not typescript. I want to create a typescript project using CLI.

Node JS version: 15.9.0
NPM version: 7.0.15

9
  • Have you tried npx create-react-app my-app --template typescript? Commented Feb 23, 2021 at 8:18
  • Of course. It works fine, But why npm not working. What is the mistake in this command? Commented Feb 23, 2021 at 8:22
  • @ChosenUser Command seems right. Works for me Node JS - 10.16 and npm - 6.14 Commented Feb 23, 2021 at 8:28
  • 1
    The docs suggest that, in v7, you need --: npm init react-app -- new-app --template typescript. Commented Feb 23, 2021 at 8:33
  • 1
    Then why have you accepted rustyBucketBay's answer below, which doesn't tell you that? It just links to the (wrong!) docs. You don't have to (and shouldn't) accept any answer that's posted, first check that they actually solve your problem. Commented Feb 23, 2021 at 8:40

1 Answer 1

3

Per the docs, in NPM v7:

Any additional options will be passed directly to the command, so npm init foo -- --hello will map to npx create-foo --hello.

This is subtly different to v6, where:

Any additional options will be passed directly to the command, so npm init foo --hello will map to npx create-foo --hello.

Note the additional -- for v7, which in your case would be:

npm init react-app -- new-app --template typescript
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.