How to update node to the latest minor version using nvm-windows?

333 Views Asked by At

In bash, I can use this command to update my current node version of nvm to the latest minor version:

nvm install $(nvm current | sed -rn "s/v([[:digit:]]+).*/\1/p") --reinstall-packages-from=$(nvm current)

How to do the same in Batch using nvm-windows?

source

1

There are 1 best solutions below

0
Ashok Dhaduk On BEST ANSWER

You can achieve the same from the window using a batch file.

Create a batch file with the following text:

@echo off 
FOR /F "tokens=* USEBACKQ" %%F IN (`nvm current`) DO (
SET var=%%F
)
SET var=%var:v=%
SET unused=%var:*.=%
CALL SET var=%%var:%unused%=%%
SET var=%var:.=%
nvm install %var%

Then run your batch file from "cmd"

I tried with the same in my system.