vitejs / create-vite-app

Create a Vite-powered app in seconds!
MIT License
573 stars 60 forks source link

Cannot install vite when user has space in username #23

Open RezaSeedin opened 4 years ago

RezaSeedin commented 4 years ago

Describe the bug

Installation Fails with an error below when running npm init vite-app

Reproduction

Possible due to my windows username has space in the name which might be the cause C:\Users\Reza Seedin\AppData

D:\_STUDY\Vue_2020\014_vite>npm init vite-app vite-test
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Seedin\AppData\Roaming\npm-cache\_npx\11336" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Reza Seedin\AppData\Roaming\npm-cache\_logs\2020-06-08T23_18_05_513Z-debug.log
Install for [ 'create-vite-app@latest' ] failed with code 1

Please provide a link to a repo that can reproduce the problem you ran into.

A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.

System Info

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Reza Seedin\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'create-vite-app@latest',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Users\\Reza',
1 verbose cli   'Seedin\\AppData\\Roaming\\npm-cache\\_npx\\11336',
1 verbose cli   '--loglevel',
1 verbose cli   'error',
1 verbose cli   '--json'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v12.16.1
4 verbose npm-session 312c571a9f0f677a
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Seedin\AppData\Roaming\npm-cache\_npx\11336 Could not install from "Seedin\AppData\Roaming\npm-cache\_npx\11336" as it does not contain a package.json file.
8 http fetch GET 304 https://registry.npmjs.org/create-vite-app 955ms (from cache)
9 silly pacote tag manifest for create-vite-app@latest fetched in 974ms
10 timing stage:rollbackFailedOptional Completed in 0ms
11 timing stage:runTopLevelLifecycles Completed in 983ms
12 verbose stack Error: ENOENT: no such file or directory, open 'D:\_STUDY\Vue_2020\014_vite\Seedin\AppData\Roaming\npm-cache\_npx\11336\package.json'
13 verbose cwd D:\_STUDY\Vue_2020\014_vite
14 verbose Windows_NT 10.0.19041
15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Reza Seedin\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-vite-app@latest" "--global" "--prefix" "C:\\Users\\Reza" "Seedin\\AppData\\Roaming\\npm-cache\\_npx\\11336" "--loglevel" "error" "--json"
16 verbose node v12.16.1
17 verbose npm  v6.14.5
18 error code ENOLOCAL
19 error Could not install from "Seedin\AppData\Roaming\npm-cache\_npx\11336" as it does not contain a package.json file.
20 verbose exit [ 1, true ]
ljcremer commented 4 years ago

Does somebody have a workaround for this yet? I cannot use Vite at all because of this.

mikeshi80 commented 3 years ago

Any progress on this? It blocked me to use Vite.

mikeshi80 commented 3 years ago

OK, I finally found a workaround.

First, open a terminal with administrator privileges.

Run the command as below:

cmd /c mklink /J "C:\Users\RezaSeedin" "C:\Users\Reza Seedin"
npm config set cache C:\Users\RezaSeedin\AppData\Roaming\npm-cache
npm config set prefix C:\Users\RezaSeedin\AppData\Roaming\npm

And now you can run the npm init vite-app correctly.

I tried, and it works for me!

I referenced this link, but the accepted answer did not work for me, I don't know why.

mikeshi80 commented 3 years ago

Since the link is the feature of NTFS, it maybe do not work if you are using FAT32(the mklink will fail), but since you are using Win10, that probably won't happen.

ahmetyasirkilic commented 3 years ago

OK, I finally found a workaround.

First, open a terminal with administrator privileges.

Run the command as below:

cmd /c mklink /J "C:\Users\RezaSeedin" "C:\Users\Reza Seedin"
npm config set cache C:\Users\RezaSeedin\AppData\Roaming\npm-cache
npm config set prefix C:\Users\RezaSeedin\AppData\Roaming\npm

And now you can run the npm init vite-app correctly.

I tried, and it works for me!

I referenced this link, but the accepted answer did not work for me, I don't know why.

Thank you!! Its Work 🚀