Windows 10 -> 'npx create-react-app myapp' command does not work because of whitespace username in file path Windows 10 -> 'npx create-react-app myapp' command does not work because of whitespace username in file path reactjs reactjs

Windows 10 -> 'npx create-react-app myapp' command does not work because of whitespace username in file path


SOLUTION

if you want to use current path that has space in username "C:\Users\Firstname Lastname\AppData\Roaming\npm-cache"you can replace the string after space with "~1"

npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global


If you have still troubles with this problem you can try this:

I was able to fix this in Windows by creating a directory junction to my users folder that didn't have a space in it. You can run a command like this in an administrative powershell:

cmd /c mklink /J "C:\Users\myname" "C:\Users\My Name"

You can then use this junction as if it were your real user directory:

npm config set cache C:\Users\myname\AppData\Roaming\npm-cache

npm config set prefix C:\Users\myname\AppData\Roaming\npm

(the above should update your user .npmrc file)

Source


Here is how I solved this:

  1. Delete npm folders from %APPDATA%
  2. Set both prefix and cache to paths without spaces. Be aware that using prefix and cache paths out of your user's folder may expose your system to security risks.
    npm config set prefix F:\PathWithoutSpace\    npm config set prefix F:\PathWithoutSpace\ --global    npm config set cache F:\PathWithoutSpace\cache    npm config set cache F:\PathWithoutSpace\cache --global
  1. Re-install packages like yarn and creat-react-app
  2. Add F:\PathWithoutSpace\ to your User's Path environment variable, which already includes an expanded version of %APPDATA%\npm, which will no longer be required.

I think it will be worth notifying the user of these problems when they install the NodeJS.