Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working if installation path contains spaces #617

Closed
migsar opened this issue Feb 16, 2021 · 10 comments
Closed

Not working if installation path contains spaces #617

migsar opened this issue Feb 16, 2021 · 10 comments

Comments

@migsar
Copy link

migsar commented Feb 16, 2021

NVM4W version: 1.1.7

This is duplicated from #611, just trying to provide some details by filling the form.

My Environment

Windows 10 Pro, pre-installed in Portuguese, currently in English

Expected Behavior

After running nvm install 12.20.2 and nvm use 12.20.2 I should be able to use npm and node.

Actual Behavior

When I try to run nvm use 12.20.2 system throws an error that has the string of the pathname, being the last part the directory that has space in its name.

Steps to reproduce the problem:

  1. Install NVM4W, set a directory with spaces as the target installation directory, ex. "C:\Program Files", "C:\Users\First Last Name".
  2. nvm install some-version
  3. nvm use some-version, this command will fail
@craigp1231
Copy link

Yes, I too am getting the same issue :(

@bzaugt
Copy link

bzaugt commented Feb 17, 2021

Same :(
I changed it to use "C:\ProgramData\nvm" to make it work.

@Japneet15597
Copy link

Same :(
I changed it to use "C:\ProgramData\nvm" to make it work.

Hey, can you pls tell me how u did that i am having the same issue. Thanks in advance

@bzaugt
Copy link

bzaugt commented Feb 25, 2021

Same :(
I changed it to use "C:\ProgramData\nvm" to make it work.

Hey, can you pls tell me how u did that i am having the same issue. Thanks in advance

Sure, just use nvm root "C:\ProgramData\nvm" then it will install node versions there. But you have to create the directory first and then manually move all versions you installed previously (or just install them again).

@Japneet15597
Copy link

Same :(
I changed it to use "C:\ProgramData\nvm" to make it work.

Hey, can you pls tell me how u did that i am having the same issue. Thanks in advance

Sure, just use nvm root "C:\ProgramData\nvm" then it will install node versions there. But you have to create the directory first and then manually move all versions you installed previously (or just install them again).

Oh ok Thanks.

@Laserbase
Copy link

As the default location "Program Files" contains a space and my "User Name" contained a space I couldn't avoid this problem.

Workaround

===== Installation folder
Where nvm-setup.exe is, I'm using ziptemp from way back
Any spaces in path/file name will defeat this workaround
in which case use/create a path without spaces.
"User Name" will be the folder name of your HOME folder not mine
Run as Administrator in "Command Prompt"

mklink /d C:\ziptemp\nvm\nvm-setup\nvm "C:\Users\User Name\AppData\Roaming\nvm"
mklink /d C:\ziptemp\nvm\nvm-setup\nodejs "C:\Program Files\nodejs"

===== settings.txt

root: C:\ziptemp\nvm\nvm-setup\nvm
path: C:\ziptemp\nvm\nvm-setup\nodejs

===== Windows Environment settings
User Variables for User Name
NVM_HOME = C:\ziptemp\nvm\nvm-setup\nvm
NVM_SYMLINK = C:\ziptemp\nvm\nvm-setup\nodejs
Sytem Variables
NVM_HOME = C:\ziptemp\nvm\nvm-setup\nvm
NVM_SYMLINK = C:\ziptemp\nvm\nvm-setup\nodejs

===== Test usage

C:\Users\User Name>nvm list

    16.2.0

C:\Users\User Name>nvm install latest
Version 16.2.0 is already installed.

C:\Users\User Name>nvm list

    16.2.0U

C:\Users\User Name>nvm use 16.2.0
Now using node v16.2.0 (64-bit)
C:\Users\User Name>nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    16.2.0    |   14.17.0    |   0.12.18    |   0.11.16    |
|    16.1.0    |   14.16.1    |   0.12.17    |   0.11.15    |
|    16.0.0    |   14.16.0    |   0.12.16    |   0.11.14    |
|   15.14.0    |   14.15.5    |   0.12.15    |   0.11.13    |
|   15.13.0    |   14.15.4    |   0.12.14    |   0.11.12    |
|   15.12.0    |   14.15.3    |   0.12.13    |   0.11.11    |
|   15.11.0    |   14.15.2    |   0.12.12    |   0.11.10    |
|   15.10.0    |   14.15.1    |   0.12.11    |    0.11.9    |
|    15.9.0    |   14.15.0    |   0.12.10    |    0.11.8    |
|    15.8.0    |   12.22.1    |    0.12.9    |    0.11.7    |
|    15.7.0    |   12.22.0    |    0.12.8    |    0.11.6    |
|    15.6.0    |   12.21.0    |    0.12.7    |    0.11.5    |
|    15.5.1    |   12.20.2    |    0.12.6    |    0.11.4    |
|    15.5.0    |   12.20.1    |    0.12.5    |    0.11.3    |
|    15.4.0    |   12.20.0    |    0.12.4    |    0.11.2    |
|    15.3.0    |   12.19.1    |    0.12.3    |    0.11.1    |
|    15.2.1    |   12.19.0    |    0.12.2    |    0.11.0    |
|    15.2.0    |   12.18.4    |    0.12.1    |    0.9.12    |
|    15.1.0    |   12.18.3    |    0.12.0    |    0.9.11    |
|    15.0.1    |   12.18.2    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/download/release

PS C:\Users\User Name> node -v
v16.2.0
PS C:\Users\User Name> nvm use 14
14.0.0
Now using node v14.0.0 (64-bit)
PS C:\Users\User Name> node -v
v14.0.0
PS C:\Users\User Name> nvm use 16.2.0
Now using node v16.2.0 (64-bit)
PS C:\Users\User Name> node -v
v16.2.0
PS C:\Users\User Name> nvm list

  * 16.2.0 (Currently using 64-bit executable)
    14.0.0

@zcoop98
Copy link

zcoop98 commented May 30, 2021

@Laserbase Symbolic links to the rescue! Great idea, that workaround worked just fine for me.

I'll add though that just changing the environmental variables to the symlink didn't work.

I had to specifically use nvm root <path-to-symlink> (in addition to changing the env. vars.) to make nvm fully use the new path.
If anyone else tries the symlink route to no avail, make sure you set the new path in nvm directly as well.

Pitfall #2 I ran into:
Make sure that the C:\Program Files\nodejs directory (or equivalent on your system) actually exists after you symlink it. If the \nodejs directory doesn't exist, nvm will simply fail to use any version of node, without giving any errors.

Once I manually (re)created C:\Program Files\nodejs, nvm worked perfectly.

@mhchristensen
Copy link

My answer from 2015 Still works

#41 (comment)

And I think its the simplest fix. in AppData\Roaming\nvm there is a settings.txt file that has your username with the space. If you run the command from that ticket it will give you a formatted path without a space you can replace in settings.txt

In my case settings.txt has

root: C:\Users\MICHAE~1\AppData\Roaming\nvm
path: C:\Program Files\nodejs

@wkrea
Copy link

wkrea commented Aug 23, 2021

Hi

For anyone that would be have this problem. I can say that, in my case i discover that problem is happening when i'm running the installer from a different partition to windows was installed.

So when i reinstall using nvm-setup.exe from C: partition, all is installed an npm is finded without problems!!, no need to modify enviroment variables in my win10.

I know that this looks crazy, but i think that this can be usefull to developers resolve this issue, or anyone need help for this now.

bye.

@coreybutler
Copy link
Owner

Closing as duplicate, resolved in 1.1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants