首页  >  问答  >  正文

尝试时出错:yarn create vite /yarn create vite my-react-app --template react

<p>我已经使用命令 <code>npm install --global yarn</code> 在 Windows 10 中安装了纱线,并使用 <code>yarn --version</code> 检查了版本,它显示了版本信息在命令中。然后我尝试使用以下命令创建一个 vite 应用程序:<code>yarn create vite</code> 但它在 cmd 中显示以下错误。如果您知道请给我解决方案。我尝试卸载并重新安装yarn,但发生了同样的错误。谢谢。</p> <p>这是cmd中的错误:</p> <pre class="brush:php;toolbar:false;">C:\DevProjects>yarn create vite yarn create v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Installed "create-vite@4.3.2" with binaries: - create-vite - cva [##] 2/2'C:\Users\Graphic' is not recognized as an internal or external command, operable program or batch file. error Command failed. Exit code: 1 Command: C:\Users\Graphic Doctor\AppData\Local\Yarn\bin\create-vite Arguments: Directory: C:\DevProjects Output: info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command. C:\DevProjects></pre></p>
P粉764003519P粉764003519386 天前621

全部回复(1)我来回复

  • P粉511985082

    P粉5119850822023-08-30 20:29:17

    我遇到了同样的问题,但找不到通过 CLI 解决它的方法。

    如果你真的坚持使用 Vite/Yarn 组合,我是这样做的:

    1. 手动转到(这是您问题中的目录)C:\Users\Graphic Doctor\AppData\Local\Yarn\bin\create-vite 并手动启动 create-vite.cmd
    2. 将会弹出一个新的命令提示符窗口,只需按照说明操作即可。
    3. 完成后,您的项目将准备就绪并位于 C:\Users\Graphic Doctor\AppData\Local\Yarn\bin 中,只需手动将其移动到您喜欢的位置即可。

    祝你好运!

    回复
    0
  • 取消回复