nvm-windows fails when the user profile path contains a space

9.7k Views Asked by At
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>nvm list

    6.7.0
  * 5.12.0 (Currently using 64-bit executable)

C:\Windows\system32>nvm use 5.12.0

When I run this command, it shows this message:

exit status 1: 'C:\Users\Mehjabin' is not recognized as an internal or external command, operable program or batch file.

How can fix this?

6

There are 6 best solutions below

0
On

You can update your settings.txt to use the old 8.3 naming convention.

For example, before:

root: C:\Program Files\nvm
path: C:\Program Files\nodejs

When changed this this, it works. After:

root: C:\Progra~1\nvm
path: C:\Progra~1\nodejs
0
On

If there is a space in the users home directory then nvm is not working and it is throwing the error that is mentioned above. Please modify the home directory to remove the space and it works.

0
On

In your windows terminal, run this command: cmd /c for %A in ("C:\Users\{Your profileName with spaces}\AppData\Roaming\nvm")

For example:

cmd /c for %A in ("C:\Users\Light Seeker\AppData\Roaming\nvm")
Output: C:\Users\LIGHTS~1\AppData\Roaming\nvm

And then modify the settings.txt, which is found in the path where the nvm was installed. For this example, it is located in C:\Users\Light Seeker\AppData\Roaming\nvm

Edit the settings.txt and change from

root: C:\Users\Light Seeker\AppData\Roaming\nvm
path: C:\Program Files\nodejs

to

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

references: https://github.com/coreybutler/nvm-windows/issues/168

2
On

Try this

  1. Create a folder in C: (just name it as nodejs-root) (it doesn't matter what name you give), then create one more folder in it (name it as nvm)
  2. now run this command in cmd

    nvm root C:\nodejs-root\nvm

    nvm install latest

    nvm use 14.4.0

(in my case as of 14th June 2020 latest is 14.4.0) hence I did nvm use 14.4.0

At this stage, you might have got an error as

elevate.cmd missing(or something of that sort)

just navigate to the location where nvm was initially installed in my case: C:\Users\Sufyan Parkar\AppData\Roaming\nvm

copy these 2 files from that folder

  1. elevate.cmd
  2. elevate.vbs

and paste it into the newly created folder located at C:\nodejs-root\nvm

0
On

I have encountered the problem also. I use windows 10 O.S. When I first installed nvm to my machine, it worked smoothly. After reboot my machine seemed not to recognize nvm.

I did my research and opened settings.txt in the nvm folder located at C:\Users\User\AppData\Roaming\nvm. I copied the nvm path. I went and added the path to my environment variables.

I opened cmd again and tried to run nvm and this time it worked.

0
On

Check that the default nvm path is added to your system path (tip - Windows key > search for 'environment variables' > select 'edit the system environment variables'. Make sure there is an entry like this (if you selected the default nvm install location):

C:\Users\*username*\AppData\Roaming\nvm\