我尝试使用以下命令创建一个React应用程序:create-react-app eth-todo-list-react这将产生以下错误:'yarnpkg' is not recognized as an internal or external command,operable program or batch file.Installing packages. This might take a couple of minutes.Installing react, react-dom, and react-scripts...'yarnpkg' is not recognized as an internal or external command,operable program or batch file.events.js:167 throw er; // Unhandled 'error' event ^Error: spawn yarnpkg ENOENT at notFoundError (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:6:26) at verifyENOENT (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:40:16) at ChildProcess.cp.emit (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:27:25) at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)Emitted 'error' event at: at ChildProcess.cp.emit (C:\Users\Aristophanes\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:30:37) at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)它应该说“成功”并初始化一个git仓库。但是我却得到了上面的错误。我尝试了各种方法的故障排除,包括更改路径和全局安装yarn,但是当我这样做之后,再次尝试创建react app时,出现此错误:The directory eth-todo-list-react contains files that could conflict: package.json yarn.lockEither try using a new directory name, or remove the files listed above.如果我删除此文件并尝试再次创建react应用,则会再次遇到第一个错误。
2 回答

万千封印
TA贡献1891条经验 获得超3个赞
尝试使用npx
命令,
npx create-react-app my-project
如果您使用npx
,则不需要像那样全局安装软件包create-react-app
。
全部告诉node -v
和npm -v

杨魅力
TA贡献1811条经验 获得超6个赞
通过create-react-app --version
在控制台中输入来获取您的create-react-app的版本。这使用2.1.5版为我成功构建。您可能需要更新您的create-react-app。 npm uninstall -g create-react-app
npm create-react-app eth-todo-list-react
应该使用最新版本的create-react-app。
添加回答
举报
0/150
提交
取消