纱线:-出口代码:1;尝试创建yarn应用程序时,命令失败



我正试图用tailwindcss创建一个next.js应用程序,但当我输入以下命令时:

yarn create next-app -e -tailwindcss demo-app-full

它总是导致一个错误,即:-

$ yarn create next-app -e -tailwindcss demo-app-full
yarn create v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-next-app@12.0.10" with binaries:
- create-next-app
'C:Users7386-85615SG' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:Users7386-85615SG 2913642AppDataLocalYarnbincreate-next-app
Arguments: -e -tailwindcss demo-app-full
Directory: C:Users7386-85615SG 2913642DesktopHEMANGPionauts
Output:
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

为了绕过这一点,我做了各种步骤,其中包括

1.     yarn upgrade
yarn add yarn
yarn info
2. npm install -g npm@latest
nvm install node
npm install -g yarn

尝试使用此解决方案中给出的步骤:-Yarn Start命令失败,退出代码为1但这也没有奏效。

我以前遇到并解决过这个问题。

让我们了解为什么会发生这种情况,以及如何避免这种情况再次发生。

原因:Windows用户名通常在用户名中包含一个空格,特别是如果您使用默认的Windows设置提示符进行设置,该提示符会根据";名字姓氏";。

解决方案:现在编辑您的用户名是不可行的。您可以将您的yarn代理和yarn配置设置到其他位置,如D:\yarnData,但这看起来并不漂亮,而且它是对在yarn设置过程中已经创建的文件夹的冗余。

首先运行以下命令:

yarn cache dir
yarn global bin

它将输出类似于:

C:Users7386-85615SG 2913642AppDataLocalYarnCachev6
C:Users7386-85615SG 2913642AppDataLocalYarnbin

解决方案1。使用用户目录简写即,您可以将目录设置为C:\Users\7386-8561~1,该目录内部等同于C:\Users\ 7386-85615SG 2913642。如何:

  1. 打开CMD

  2. 导航到C:Users并运行命令dir /x这应该输出这样的内容Directory of C:Users

    23-06-2022  00:06    <DIR>                       .
    23-06-2022  00:06    <DIR>                       ..
    21-11-2020  13:33    <DIR>                       Public
    28-06-2022  11:50    <DIR>          SIDDHA~1     Siddharth Shetty
    

    记下用户旁边的别名。在我的情况下,它是SIDDHA~1,对你来说,它可能是7386~1

  3. 运行命令:

    yarn config set cache-folder "C:UsersSIDDHA~1AppDataLocalYarnCache" (without the V6)
    yarn config set prefix "C:UsersSIDDHA~1AppDataLocalYarn" (without the bin)
    
  4. 重新加载shell并运行命令-它应该可以工作。

解决方案2。设置指向用户文件夹的快捷方式。即,您可以创建一个mklink,将C:\Users\NameSurname设置为指向=>C: \用户\ 7386-85615SG 2913642。如何:

  1. 在管理员模式下打开CMD(不是powershell,因为该命令仅为CMD(

  2. 使用mklink命令创建目录连接(目录硬链接(:

    mklink /J "C:UsersNameSurname" "C:Users7386-85615SG 2913642"
    
  3. 运行命令:

    yarn config set cache-folder "C:UsersNameSurnameAppDataLocalYarnCache"(不带V6(

    yarn config set prefix "C:UsersNameSurnameAppDataLocalYarn"(无仓(

  4. 重新加载shell并运行它应该工作的命令。

这里的路径很可能是文件夹名称中的C:Users7386-85615SG 2913642空格显示为问题的原因,这不是一个好主意,请尝试创建一个类似C:MyProject的简单结构,然后重试。

最新更新