javascript - 尝试创建 React 应用程序时出现 Yarn 错误

标签 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-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 应用程序时,我收到此错误:

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 应用程序,我会再次收到第一个错误。

最佳答案

尝试使用npx命令,

npx create-react-app my-project

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

全部告诉node -vnpm -v

关于javascript - 尝试创建 React 应用程序时出现 Yarn 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55851470/

相关文章:

javascript - Redux 状态改变但不重新渲染

reactjs - 我在react-native和redux中处理API调用的地方

node.js - 使用 Yarn 依赖项为 Node 应用程序构建 Docker 镜像

reactjs - 在 yarn 启动命令中显示错误表示您的锁文件中似乎不存在此包;尝试进行安装以更新您的分辨率

javascript - 不能在 javascript 中使用 "download"作为函数名

javascript - 如何从 jquery datePicker 获取选定的日期

javascript - ScrollIntoView 打破溢出滚动

react-router - react 路由器 : Cannot read property 'pathname' of undefined

node.js - 请求错误 : getaddrinfo ENOTFOUND github. com

javascript - 在 Angular 1.5 中为 ng-pattern 生成正则表达式