javascript - When I try to run npm create vite@latest my-react-js-app -- --template react -y it says: npm warn Unknown cli confi

I'm trying to create a new React app using Vite with the following command from Vite official site

I'm trying to create a new React app using Vite with the following command from Vite official site:

npm create vite@latest my-react-js-app -- --template react -y

However, I get this warning:

npm WARN Unknown cli config "--template"

The command does not execute as expected. How can I fix this issue?

System details:

  • Node.js version: v22.14.0
  • NPM version: v11.2.0
  • OS: Windows 10 Pro

I also tried running:

npm create vite@latest my-react-js-app --template react

but the issue persists.

How can I resolve this and properly create a Vite React project in a single command without being prompted to select the framework (vanilla, Vue, React, etc.) and the variant (JavaScript or TypeScript) I want to use for my app?

I'm trying to create a new React app using Vite with the following command from Vite official site:

npm create vite@latest my-react-js-app -- --template react -y

However, I get this warning:

npm WARN Unknown cli config "--template"

The command does not execute as expected. How can I fix this issue?

System details:

  • Node.js version: v22.14.0
  • NPM version: v11.2.0
  • OS: Windows 10 Pro

I also tried running:

npm create vite@latest my-react-js-app --template react

but the issue persists.

How can I resolve this and properly create a Vite React project in a single command without being prompted to select the framework (vanilla, Vue, React, etc.) and the variant (JavaScript or TypeScript) I want to use for my app?

Share Improve this question edited Mar 7 at 9:08 jonrsharpe 122k30 gold badges268 silver badges476 bronze badges asked Mar 7 at 9:02 Vishal RavanankVishal Ravanank 131 silver badge3 bronze badges 5
  • 1 I can't reproduce the problem. The first snippet works as expected without warning. Is it possible that you use an old, cached version of create-vite? – jabaa Commented Mar 7 at 9:32
  • It was working well on the order version of node and Npm but recently I updated to the latest versions and I ran into this problem. I have mentioned the version details above please cross check with your version. – Vishal Ravanank Commented Mar 10 at 5:28
  • I've asked for the version of create-vite. I can't find it in the question. – jabaa Commented Mar 10 at 8:27
  • vite virsion is: "^6.2.0" – Vishal Ravanank Commented Mar 11 at 7:49
  • I've asked for the version of create-vite, not vite. – jabaa Commented Mar 11 at 8:32
Add a comment  | 

4 Answers 4

Reset to default 0

Ttry using npx instead:

npx create-vite@latest my-react-js-app --template react

Alternative (Explicit Way)

If npm create vite still causes issues, you can use yarn or pnpm:

Using Yarn

yarn create vite my-react-js-app --template react

Using pnpm

pnpm create vite my-react-js-app --template react

Force Clearing NPM Cache

If the issue persists, try clearing your npm cache:

npm cache clean --force

Then retry the command.

Ensure Compatibility

Your Node.js (v22.14.0) is very new, and there might be compatibility issues. Try downgrading to Node.js v20 (LTS) using nvm or nvm-windows:

nvm install 20
nvm use 20

Then, rerun the command.

See https://github/vitejs/vite/issues/17882. Use triple dash on Windows.

npm create vite@latest my-react-js-app --- --template react -y

Just do

npm create vite@latest my-react-js-app 

It will ask what framework you want to use and its variation. It will the same template vite has added in template repo

Ok, i found the way to do that. using the following command:

npx create-vite@latest my-app-name --template react

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744940271a4602277.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信