1

I am trying to create a next.js app with tailwindcss, but when I enter the following command:

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

It always results with an error, viz:-

$ 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:\Users\7386-85615SG' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Users\7386-85615SG 2913642\AppData\Local\Yarn\bin\create-next-app
Arguments: -e -tailwindcss demo-app-full
Directory: C:\Users\7386-85615SG 2913642\Desktop\HEMANG\Pionauts
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

To bypass this, I have done various steps, which include

 1.     yarn upgrade
        yarn add yarn
        yarn info

 2. npm install -g npm@latest
    nvm install node
    npm install -g yarn

Tried using the steps given in this solution:- Yarn Start Command failed with exit code 1 but this also didn't work.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Hemang Joshi
  • 158
  • 1
  • 5
  • 13

2 Answers2

2

I've had and solved this issue before.

Let's understand why this happens and how to avoid it happening ever again.

Cause: Windows usernames usually contain a space in the username especially if you set it up using the default windows setup prompt which creates your user based on "FirstName LastName".

Solution(s): Now editing your username isn't feasible. You could set your yarn proxy and yarn config to some other location like D:\yarnData but that doesn't look pretty and it is a redundancy to folders already created during the yarn setup.

first run these commands:

 yarn cache dir
 yarn global bin

It will output to something like:

C:\Users\7386-85615SG 2913642\AppData\Local\Yarn\Cache\v6
C:\Users\7386-85615SG 2913642\AppData\Local\Yarn\bin

Solution 1. Use the user directory shorthand i.e you can set the directory to say say C:\Users\7386-8561~1 that internally is equesl to C:\Users\7386-85615SG 2913642 . How:

  1. Open CMD

  2. Navigate to C:\Users and run the command dir /x This should output something like this 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
    

    Note down the alias next to your user. Here in my case it is SIDDHA~1, for you it could be 7386~1

  3. Run commands:

    yarn config set cache-folder "C:\Users\SIDDHA~1\AppData\Local\Yarn\Cache" (without the V6)
    yarn config set prefix "C:\Users\SIDDHA~1\AppData\Local\Yarn" (without the bin)
    
  4. Reload your shell and run the commands - it should work.

Solution 2. Set up a shortcut to point to your user folder. i.e you can create a mklink that sets say C:\Users\NameSurname to point to => C:\Users\7386-85615SG 2913642 . How:

  1. Open CMD in Administrator mode (not powershell as the command is cmd only)

  2. Create a directory junction (directory hard link) using the mklink command:

    mklink /J "C:\Users\NameSurname" "C:\Users\7386-85615SG 2913642"
    
  3. Run commands:

    yarn config set cache-folder "C:\Users\NameSurname\AppData\Local\Yarn\Cache" (without the V6)

    yarn config set prefix "C:\Users\NameSurname\AppData\Local\Yarn" (without the bin)

  4. Reload your shell and run the commands it should work.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
1

The path here is most probably the cause C:\Users\7386-85615SG 2913642 Spaces in folder names show up as issues and are not a good idea, try creating a simple structure like C:\MyProject and retry.

Ramakay
  • 2,919
  • 1
  • 5
  • 21