As stated in title, the Yarn PM(package manager), that I just installed in my system(Windows 11 64Bit) doesn't work if there's space(s) in my UserProfile folder path.
My User folder name is "Firstname Surname" and thus when I try yarn create nuxt-app hello_world
, after a few success steps, it throws the below error and exits:
- create-nuxt-app
'C:\Users\Firstname' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Users\Firstname Surname\AppData\Local\Yarn\bin\create-nuxt-app
Arguments: hello_world
Directory: <path/to/my/project>
Output:
I already tried doing what this answer suggested, but in vain, I guess the yarn
doesn't use npm-cache
for create-app-<x>
commands.
Am I wrong in assuming that ? NuxtJS is installed in my system, so no issues there.
How can I fix the said error ? Ofcourse I would try to avoid changing my User profile folder name.
First, run these commands:
yarn cache dir
yarn global bin
An example output should look similar to:
C:\Users\Firstname Lastname\AppData\Local\Yarn\Cache\v6
C:\Users\Firstname Lastname\AppData\Local\Yarn\bin
Copy both outputs, and run the following two commands, with slight modification according to your username Firstname:
yarn config set cache-folder "C:\Users\Firstname~1\AppData\Local\Yarn\Cache"
yarn config set prefix "C:\Users\Firstname~1\AppData\Local\Yarn"
Attempt to use yarn create, if it doesn't work try Solution 2.
Problematic path used as example: C:\Users\FirstName LastName
Close any running shell Run cmd in Administrative Mode (mklink is a feature of cmd, and won't work in PowerShell)
Create a directory junction (directory hard link) using the mklink command:
mklink /J "C:\Users\FirstNameLastName" "C:\Users\FirstName LastName"
Run commands
yarn cache dir
yarn global bin
Take note of the output, they will look something like this:
C:\Users\FirstName LastName\AppData\Local\Yarn\Cache\v6
C:\Users\FirstName LastName\AppData\Local\Yarn\bin
Run commands
yarn config set cache-folder "C:\Users\FirstNameLastName\AppData\Local\Yarn\Cache"
yarn config set prefix "C:\Users\FirstNameLastName\AppData\Local\Yarn"
Reload your shell
Run commands
yarn cache dir
yarn global bin
Confirm the new output
Assuming the paths are correctly changed, yarn create should now hopefully be working.
Yarnpkg. “Cannot Run Yarn Create if Yarn Is in a Folder Where the File Path Has a Space · Issue #6851 · Yarnpkg/Yarn.” GitHub, github.com/yarnpkg/yarn/issues/6851.