getting exit status 1 when I run the command nvm use 12.18.0
Asked Answered
D

8

12

I have installed nvm on my windows machine and with nvm, I installed 2 node versions but it's not letting me change the version.

Microsoft Windows [Version 10.0.16299.64]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Windows\system32>nvm use 12.18.0
exit status 1: 'C:\Users\Sarmad' is not recognized as an internal or external command,
operable program or batch file.


C:\Windows\system32>nvm version
1.1.7

C:\Windows\system32>nvm ls

  * 15.8.0 (Currently using 64-bit executable)
    12.18.0

C:\Windows\system32>nvm use 12.18.0
exit status 1: 'C:\Users\Ali' is not recognized as an internal or external command,
operable program or batch file.
Dearman answered 4/2, 2021 at 13:59 Comment(2)
Please use the developers GitHub pages to check for these issues, before resorting to asking questions on a general programming site. What you have reported is a known issue, because the software you are using has not been written to work properly on the target Operating System.Sympathize
Okay! Thanks @SympathizeDearman
U
10

Ali you are getting this error because you are installing nvm in the default location. And that is your user's directory. Nvm for windows is an attempt to port from the linux and currently does not support spaces in the path.

I spent several hours trying to figure this out and none of these solutions work for me. If you install nvm in c:\tools\ directory, (you might already have one if not just create it) should solve the problem.

UPDATE Jan - 2023 The writer of NVM for Windows has decided to deprecate it and there will be something coming up to replace it. See the announcement:

https://github.com/coreybutler/nvm-windows/wiki/Runtime

From the link:

I intend to deprecate NVM for Windows after Runtime is released. There are two things slowing work on Runtime. First, client engagements. I am wrapping up the most time-consuming project this quarter and will have much more time in early spring 2023. The other thing slowing down Runtime development is this project. So, I'm freezing feature development on NVM for Windows.

Uttica answered 6/8, 2021 at 13:52 Comment(1)
Please see the @Naxos answer below before you start moving files or re-installing nvm - may save you some time.Naxos
P
16

I had the same issue in a windows environment. I solved it by running the nvm commands in the command line cmd in the root directory C:/ rather than the integrated terminal of vscode.

  • Run cmd as an administrator
  • Download the node version you want to use and use it
$ nvm download 12.18.0
$ nvm use 12.18.0

If you see the same error, you should configue the PATH in the Environment Variables like this answer is saying.

  • Go back to the other directory or in VsCode and try
node -v

and you'll see that you're using 12.18.0

Phototube answered 4/12, 2021 at 14:44 Comment(0)
U
10

Ali you are getting this error because you are installing nvm in the default location. And that is your user's directory. Nvm for windows is an attempt to port from the linux and currently does not support spaces in the path.

I spent several hours trying to figure this out and none of these solutions work for me. If you install nvm in c:\tools\ directory, (you might already have one if not just create it) should solve the problem.

UPDATE Jan - 2023 The writer of NVM for Windows has decided to deprecate it and there will be something coming up to replace it. See the announcement:

https://github.com/coreybutler/nvm-windows/wiki/Runtime

From the link:

I intend to deprecate NVM for Windows after Runtime is released. There are two things slowing work on Runtime. First, client engagements. I am wrapping up the most time-consuming project this quarter and will have much more time in early spring 2023. The other thing slowing down Runtime development is this project. So, I'm freezing feature development on NVM for Windows.

Uttica answered 6/8, 2021 at 13:52 Comment(1)
Please see the @Naxos answer below before you start moving files or re-installing nvm - may save you some time.Naxos
S
5

Try to install the nvm directly in C:/ or in other folder without spaces in the PATH.

Sandbank answered 28/7, 2021 at 23:48 Comment(0)
N
1

You'll need to start powershell or Command Prompt as Administrator to use nvm-windows. See here https://github.com/coreybutler/nvm-windows

Nitrosyl answered 18/1, 2022 at 14:34 Comment(0)
R
1

Spacing in the path is the problem.

You can run:

nvm root and find the root folder

then, copy the contents to another folder without any spaces on the path

After that move the nvm root to that folder by running the command below (with full path)

nvm root [path]

Ream answered 5/2, 2023 at 16:25 Comment(0)
F
1

To resolve this issue, all you have to do is simply add the path of the bin of the node_modules to the environment variables. The path will be: C:\Program Files\nodejs\node_modules\npm\bin (Do not copy this path, this is an example. You can find the path of bin in your C drive)

Fango answered 30/4, 2023 at 13:0 Comment(0)
H
0

After running nvm install "version No" run CMD as administrater and then run nvm use "version No" and It will work fine.

Hazem answered 23/5, 2023 at 15:10 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Palatal
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewCointon
N
0

Following on from @saddamhr's answer, if you have your nvm root in C:\Program Files, then it is a simple matter to fix this issue.

Step 1: Find out the short name of C:\Program Files using dir /x c:\ (use a cmd window, not PowerShell). It will be something like C:\PROGRA~1.

Step 2: Type nvm root C:\PROGRA~1\nvm (or whatever you got back from step 1)

You should now be able to run nvm use {version}.

(If this fails, you may need to edit your environment variables NVM_HOME and NVM_SYMLINK to match the output from step 1.)

Given we're working with environment variables, a reboot may be in order, but shouldn't strictly be necessary.

Naxos answered 5/6, 2024 at 17:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.