Node.js Command Prompt; Starting in Z: instead of C:

AzKai picture AzKai · Mar 18, 2015 · Viewed 7.4k times · Source

Node.js Command Prompt is starting in my Z: drive, which is a shared drive administered by my corporation. Because I only have access to it over the ethernet or VPN, it makes my connection very slow when trying to run GULP and browser sync.

Firstly, will running it on the local disk speed up the compiling and syncing?

Second, if Node is installed properly in the C: drive (which it is), why is it starting in Z:? Is my computer telling Node that the "home directory" is the Z: drive? (In which case, would I only have to change the "Home directory" to get node to open in C:?)

I do not have Admin of my computer because my company has very strict security. So I cannot change paths or home directories myself. (I can ask them to do it, but I need to just hand them the solution for doing so...)

Thanks for any help. I really need to be able to use GULP and Sync without it taking a minute and a half each time to run a task.

Edit

The "Start in" is already set to "C:\Program Files\nodejs\" and in the command prompt when I do: "cd .." or "cd C:\" or any of the ones of that ilk, it still just takes me back to the Z Drive.

Answer

Kevin B picture Kevin B · Mar 18, 2015

If you read through the shortcut, you'll see that it executes a .bat file in the node.js directory. Below is that file:

@echo off
rem Ensure this Node.js and npm are first in the PATH
set PATH=%APPDATA%\npm;%~dp0;%PATH%

setlocal enabledelayedexpansion
pushd "%~dp0"

rem Figure out the node version.
set print_version=.\node.exe -p -e "process.versions.node + ' (' + process.arch + ')'"
for /F "usebackq delims=" %%v in (`%print_version%`) do set version=%%v

rem Print message.
if exist npm.cmd (
  echo Your environment has been set up for using Node.js !version! and npm.
) else (
  echo Your environment has been set up for using Node.js !version!.
)

popd
endlocal

rem If we're in the node.js directory, change to the user's home dir.
if "%CD%\"=="%~dp0" cd /d "%HOMEDRIVE%%HOMEPATH%"

To change where it opens, simply change the last line.

rem If we're in the node.js directory, change to the C drive.
if "%CD%\"=="%~dp0" cd /d "C:\the\directory\i\wish\to\start\in"

I wouldn't be surprised if this change gets overwritten when you update node.js. If you have access to it, updating the environment variables to change your home drive and home path would be a more long-term solution (assuming that isn't also being tampered with by the network security)