当运行此命令来创建 React 应用程序时,它会创建该应用程序,但它也给了我一个错误。这个错误是什么意思以及如何解决它?
npx create-react-app mynews-app
231 packages are looking for funding
run `npm fund` for details
Git repo not initialized Error: Command failed: git --version
at checkExecSyncError (node:child_process:885:11)
at execSync (node:child_process:957:15)
at tryGitInit (C:\Users\sapar\OneDrive\Desktop\Project\ReactJs\mynews-app\node_modules\react-scripts\scripts\init.js:46:5)
at module.exports (C:\Users\sapar\OneDrive\Desktop\Project\ReactJs\mynews-app\node_modules\react-scripts\scripts\init.js:276:7)
at [eval]:3:14
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:307:38)
at node:internal/process/execution:79:19
at [eval]-wrapper:6:22 {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 13968,
stdout: null,
stderr: null
}
Installing template dependencies using npm...
added 55 packages in 9s
231 packages are looking for funding
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd mynews-app
npm start
Happy hacking!
首先确保您的计算机上安装了 git。这个非常重要。在终端中运行
git
进行验证。如果您得到输出“未找到命令”,请继续进行 Windows 的安装此处
无论您是否安装了 git,都需要在全局配置 git 用户名和电子邮件。
$ git config --global user.name "Your Username"
$ git config --global user.email [email protected]
这样应该可以基本解决问题了。您可以创建另一个反应应用程序,它应该会清除错误。 :)