我想使用 typescript 模板创建一个 React 应用程序。
npm 版本:10.2.4
节点版本:20.1.1
我尝试了以下命令但出现错误:
第一个命令
npx create-react-app my-app --template typescript
出现错误:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path D:\usr
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'D:\usr'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
第二个命令
npm create-react-app my-app --template typescript
出现错误:
Unknown command: "create-react-app"
To see a list of supported npm commands, run:
npm help```
提示和建议
create-react-app 现在有点过时了,试试 vite,这个加速构建也可以 https://vitejs.dev/guide/
npm create vite@latest my-react-app ---template react-ts