创建反应应用程序时出错 > Git 提交未创建错误:命令失败:git commit -m“使用创建反应应用程序初始化项目”

Irv*_*dez 5 windows git node.js reactjs yarnpkg

我是 Windows 用户,我安装了yarn、node js、git、npm。在我使用命令 npx create-react-app my-app 创建反应应用程序时开始创建,但几乎在最后我标记了此错误:

\n\n
PS C:\\React> npx create-react-app my-app\n\nCreating a new React app in C:\\React\\my-app.\n\nInstalling packages. This might take a couple of minutes.\nInstalling react, react-dom, and react-scripts with cra-template...\n\nyarn add v1.22.4\n[1/4] Resolving packages...\n[2/4] Fetching packages...\ninfo fsevents@1.2.12: The platform "win32" is incompatible with this module.\ninfo "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.\ninfo fsevents@2.1.2: The platform "win32" is incompatible with this module.\ninfo "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.\n[3/4] Linking dependencies...\nwarning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".\n[4/4] Building fresh packages...\nsuccess Saved lockfile.\nsuccess Saved 13 new dependencies.\ninfo Direct dependencies\n\xe2\x94\x9c\xe2\x94\x80 cra-template@1.0.3\n\xe2\x94\x9c\xe2\x94\x80 react-dom@16.13.1\n\xe2\x94\x9c\xe2\x94\x80 react-scripts@3.4.1\n\xe2\x94\x94\xe2\x94\x80 react@16.13.1\ninfo All dependencies\n\xe2\x94\x9c\xe2\x94\x80 @babel/plugin-transform-flow-strip-types@7.9.0\n\xe2\x94\x9c\xe2\x94\x80 @babel/plugin-transform-runtime@7.9.0\n\xe2\x94\x9c\xe2\x94\x80 @babel/plugin-transform-typescript@7.9.4\n\xe2\x94\x9c\xe2\x94\x80 @babel/preset-typescript@7.9.0\n\xe2\x94\x9c\xe2\x94\x80 babel-preset-react-app@9.1.2\n\xe2\x94\x9c\xe2\x94\x80 cra-template@1.0.3\n\xe2\x94\x9c\xe2\x94\x80 eslint-config-react-app@5.2.1\n\xe2\x94\x9c\xe2\x94\x80 react-dev-utils@10.2.1\n\xe2\x94\x9c\xe2\x94\x80 react-dom@16.13.1\n\xe2\x94\x9c\xe2\x94\x80 react-error-overlay@6.0.7\n\xe2\x94\x9c\xe2\x94\x80 react-scripts@3.4.1\n\xe2\x94\x9c\xe2\x94\x80 react@16.13.1\n\xe2\x94\x94\xe2\x94\x80 scheduler@0.19.1\nDone in 19.76s.\n\nInitialized a git repository.\n\nInstalling template dependencies using yarnpkg...\nyarn add v1.22.4\n[1/4] Resolving packages...\n[2/4] Fetching packages...\ninfo fsevents@2.1.2: The platform "win32" is incompatible with this module.\ninfo "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.\ninfo fsevents@1.2.12: The platform "win32" is incompatible with this module.\ninfo "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.\n[3/4] Linking dependencies...\nwarning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".\nwarning " > @testing-library/user-event@7.2.1" has unmet peer dependency "@testing-library/dom@>=5".\n[4/4] Building fresh packages...\nsuccess Saved lockfile.\nsuccess Saved 20 new dependencies.\ninfo Direct dependencies\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/jest-dom@4.2.4\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/react@9.5.0\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/user-event@7.2.1\n\xe2\x94\x9c\xe2\x94\x80 react-dom@16.13.1\n\xe2\x94\x94\xe2\x94\x80 react@16.13.1\ninfo All dependencies\n\xe2\x94\x9c\xe2\x94\x80 @babel/runtime-corejs3@7.9.2\n\xe2\x94\x9c\xe2\x94\x80 @sheerun/mutationobserver-shim@0.3.3\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/dom@6.16.0\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/jest-dom@4.2.4\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/react@9.5.0\n\xe2\x94\x9c\xe2\x94\x80 @testing-library/user-event@7.2.1\n\xe2\x94\x9c\xe2\x94\x80 @types/prop-types@15.7.3\n\xe2\x94\x9c\xe2\x94\x80 @types/react-dom@16.9.6\n\xe2\x94\x9c\xe2\x94\x80 @types/react@16.9.34\n\xe2\x94\x9c\xe2\x94\x80 @types/testing-library__dom@7.0.1\n\xe2\x94\x9c\xe2\x94\x80 @types/testing-library__react@9.1.3\n\xe2\x94\x9c\xe2\x94\x80 css.escape@1.5.1\n\xe2\x94\x9c\xe2\x94\x80 csstype@2.6.10\n\xe2\x94\x9c\xe2\x94\x80 dom-accessibility-api@0.3.0\n\xe2\x94\x9c\xe2\x94\x80 min-indent@1.0.0\n\xe2\x94\x9c\xe2\x94\x80 react-dom@16.13.1\n\xe2\x94\x9c\xe2\x94\x80 react@16.13.1\n\xe2\x94\x9c\xe2\x94\x80 redent@3.0.0\n\xe2\x94\x9c\xe2\x94\x80 strip-indent@3.0.0\n\xe2\x94\x94\xe2\x94\x80 wait-for-expect@3.0.2\nDone in 6.53s.\nRemoving template package using yarnpkg...\n\nyarn remove v1.22.4\n[1/2] Removing module cra-template...\n[2/2] Regenerating lockfile and installing missing dependencies...\ninfo fsevents@2.1.2: The platform "win32" is incompatible with this module.\ninfo "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.\ninfo fsevents@1.2.12: The platform "win32" is incompatible with this module.\ninfo "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.\nwarning " > @testing-library/user-event@7.2.1" has unmet peer dependency "@testing-library/dom@>=5".\nwarning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".\nsuccess Uninstalled packages.\nDone in 5.67s.\nGit commit not created Error: Command failed: git commit -m "Initialize project using Create React App"\n    at checkExecSyncError (child_process.js:630:11)\n    at execSync (child_process.js:666:15)\n    at tryGitCommit (C:\\React\\my-app\\node_modules\\react-scripts\\scripts\\init.js:62:5)\n    at module.exports (C:\\React\\my-app\\node_modules\\react-scripts\\scripts\\init.js:334:25)\n    at [eval]:3:14\n    at Script.runInThisContext (vm.js:120:20)\n    at Object.runInThisContext (vm.js:311:38)\n    at Object.<anonymous> ([eval]-wrapper:10:26)\n    at Module._compile (internal/modules/cjs/loader.js:1156:30)\n    at evalScript (internal/process/execution.js:94:25) {\n  status: 128,\n  signal: null,\n  output: [ null, null, null ],\n  pid: 10420,\n  stdout: null,\n  stderr: null\n}\nRemoving .git directory...\n\nSuccess! Created my-app at C:\\React\\my-app\nInside that directory, you can run several commands:\n\n  yarn start\n    Starts the development server.\n\n  yarn build\n    Bundles the app into static files for production.\n\n  yarn test\n    Starts the test runner.\n\n  yarn eject\n    Removes this tool and copies build dependencies, configuration files\n    and scripts into the app directory. If you do this, you can\xe2\x80\x99t go back!\n\nWe suggest that you begin by typing:\n\n  cd my-app\n  yarn start\n\nHappy hacking!\nPS C:\\React>\n
Run Code Online (Sandbox Code Playgroud)\n\n

另外,当我尝试提升创建的反应应用程序时,我收到此错误:

\n\n
PS C:\\React> cd .\\my-app\\\nPS C:\\React\\my-app> yarn start\nyarn run v1.22.4\n$ react-scripts start\ni \xef\xbd\xa2wds\xef\xbd\xa3: Project is running at http://192.168.56.1/\ni \xef\xbd\xa2wds\xef\xbd\xa3: webpack output is served from\ni \xef\xbd\xa2wds\xef\xbd\xa3: Content not from webpack is served from C:\\React\\my-app\\public\ni \xef\xbd\xa2wds\xef\xbd\xa3: 404s will fallback to /\nStarting the development server...\n\nevents.js:287\n      throw er; // Unhandled \'error\' event\n      ^\n\nError: spawn cmd ENOENT\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)\n    at onErrorNT (internal/child_process.js:469:16)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21)\nEmitted \'error\' event on ChildProcess instance at:\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)\n    at onErrorNT (internal/child_process.js:469:16)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21) {\n  errno: \'ENOENT\',\n  code: \'ENOENT\',\n  syscall: \'spawn cmd\',\n  path: \'cmd\',\n  spawnargs: [ \'/s\', \'/c\', \'start\', \'""\', \'/b\', \'"http://localhost:3000"\' ]\n}\nerror Command failed with exit code 1.\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\nPS C:\\React\\my-app>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我该如何解决它?

\n

San*_*ago 13

配置你的 git 身份:

git config --global user.name <yourName>
git config --global user.email <yourEmail>
Run Code Online (Sandbox Code Playgroud)

例如,您可以使用您的 GitHub 帐户数据。