Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试创建React应用程序时出现错误_Javascript_Reactjs_Yarnpkg - Fatal编程技术网

Javascript 尝试创建React应用程序时出现错误

Javascript 尝试创建React应用程序时出现错误,javascript,reactjs,yarnpkg,Javascript,Reactjs,Yarnpkg,我尝试使用以下命令创建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-do

我尝试使用以下命令创建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托管。但是我得到了上面的错误。我尝试过各种方法的故障排除,包括更改路径和全局安装纱线,但当我这样做,然后再次尝试创建react应用程序时,我发现以下错误:

The directory eth-todo-list-react contains files that could conflict:

  package.json
  yarn.lock

Either try using a new directory name, or remove the files listed above.

如果删除此文件并再次尝试创建react应用程序,则会再次出现第一个错误。

在控制台中键入
创建react应用程序--version
以获取创建react应用程序的版本。这为我使用2.1.5版成功构建。您可能需要更新您的create react应用程序。
npm卸载-g创建反应应用程序
npm创建react应用程序eth todo list react

应使用最新版本的create react app。

尝试使用
npx
命令

npx创建react应用程序我的项目

如果您使用
npx
,则不需要像
create react app
那样全局安装软件包


所有这些都告诉
节点-v
npm-v

当修改路径时,当前打开的cmd窗口不受影响,您需要关闭并重新打开它们。关闭和打开cmd没有区别。我总是会遇到同样的错误。尝试先使用“npm install Thread-g”安装Thread。已经尝试全局安装Thread,我也会遇到同样的错误。不起作用,我会遇到同样的第二个冲突文件错误。现在这确实起作用了。谢谢。你能告诉我npx到底是什么吗?查看这篇博文了解更多信息