Override System Environment variable path in windows (not admin access)
Asked Answered
F

2

11

Issue is very peculiar, I have a version of NodeJS installed in Windows (in program files x86) and a newer version of software downloaded and exe is extracted.

The installed NodeJS (node.exe) 's path is included in system path variable. I added the extracted path to user environment path variable. After doing my bit of RTFM I came to know that in case path variable both system and user environment variables are combined and the system gets the precedence.

Is there any way I can override (or nullify) the system variable's PATH with user variable's path ? or can the precedence of reading variables be changed ?

F answered 14/3, 2017 at 13:33 Comment(3)
using process.env you can get the environment of your systemDiluent
The user-related environment variables take precedence over the system-related ones, unless you explicitly tell something else...Encyclopedic
@Encyclopedic Not the case for %PATH%. System path is concatenated with user path, so system path is searched first. See Prevent Windows System %PATH% from being prepended to user %PATH%? - Super User.Lido
W
8

In cmd, type

set PATH=D:\Path_To_Local_Folder;%PATH%
node

It will start node from your local folder.

Walrath answered 14/3, 2017 at 15:8 Comment(3)
again PATH is resolved as taken from sys variables first and then user variables and then only shell variableF
that's not correct...in the command line you only have one PATH variable that you can modify, for the current cmd session.Walrath
C:\Users\sij>node -v v4.4.3 C:\Users\sij>set PATH = C:\Users\sij\Downloads\git\bin;C:\Users\sij\ Downloads\node-v6.10.0-win-x64\node-v6.10.0-win-x64;%PATH% C:\Users\sij>node -v v4.4.3F
T
2

Using Powershell you can set the folder Node runs from so that it picks up the new version of Node for that instance of Powershell.

  1. Open Powershell
  2. Set the path variable to be your node folder $env:Path = "C:\yournodefolder";
  3. Running node --version should now display the version of node from your new folder.
Targett answered 17/7, 2017 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.