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:
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?
Ttry using npx
instead:
npx create-vite@latest my-react-js-app --template react
If npm create vite
still causes issues, you can use yarn
or pnpm
:
yarn create vite my-react-js-app --template react
pnpm create vite my-react-js-app --template react
If the issue persists, try clearing your npm cache:
npm cache clean --force
Then retry the command.
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.