DEV Community

Cover image for How to Install Node.js and Android Development Tools on a Custom Drive in Windows
K-kibet for Codespear

Posted on

How to Install Node.js and Android Development Tools on a Custom Drive in Windows

Your complete guide to managing development tool installations on Windows when you need them on a different drive.


Introduction

As developers, we often face storage constraints on our primary C: drive, especially when working with multiple development environments, Android projects, and Node.js applications. This comprehensive guide walks you through the process of installing and configuring essential development tools on alternative drives in Windows.

The Challenge: Moving Beyond the C: Drive

By default, most development tools install to the C: drive. However, with large SDKs, multiple Node.js projects, and various dependencies, you might quickly run out of space. Here's how to take control of your development environment installation locations.

Part 1: Installing Node.js on D: Drive with Chocolatey

Understanding Chocolatey Installation Locations

Chocolatey, the Windows package manager, uses several environment variables to determine installation locations:

  • ChocolateyInstall: Main Chocolatey directory
  • ChocolateyBinRoot: Binary tools location
  • ChocolateyToolsLocation: Additional tools directory

Step-by-Step Installation Process

Method 1: Environment Variable Approach

# Set custom installation locations
$env:ChocolateyInstall = 'D:\Chocolatey'
$env:ChocolateyBinRoot = 'D:\Tools'
$env:ChocolateyToolsLocation = 'D:\Tools'

# Install Node.js LTS
choco install -y nodejs-lts
Enter fullscreen mode Exit fullscreen mode

Method 2: Package-Specific Parameters

# Direct installation to custom directory
choco install -y nodejs-lts --params="'/InstallDir:D:\nodejs'"
Enter fullscreen mode Exit fullscreen mode

Method 3: Permanent Configuration

For a permanent setup, set system environment variables:

[Environment]::SetEnvironmentVariable("ChocolateyInstall", "D:\Chocolatey", "Machine")
[Environment]::SetEnvironmentVariable("ChocolateyBinRoot", "D:\Tools", "Machine")
[Environment]::SetEnvironmentVariable("ChocolateyToolsLocation", "D:\Tools", "Machine")
Enter fullscreen mode Exit fullscreen mode

Important Note: Always run PowerShell as Administrator when changing system-wide settings or installing software that requires system modifications.

Common Issues and Solutions

Administrator Rights Required

# Error: "Chocolatey detected you are not running from an elevated command shell"
# Solution: Run PowerShell as Administrator
Enter fullscreen mode Exit fullscreen mode

Package Already Installed

# If Node.js is already installed on C: drive
choco install -y nodejs-lts --force --params="'/InstallDir:D:\nodejs'"

# Or uninstall first, then reinstall
choco uninstall nodejs-lts -y
choco install -y nodejs-lts --params="'/InstallDir:D:\nodejs'"
Enter fullscreen mode Exit fullscreen mode

Part 2: Finding and Configuring Android Development Tools

Locating Android SDK and JDK

When working with Android development, you need to locate or install two key components:

  1. Java Development Kit (JDK)
  2. Android SDK

Finding Existing Installations

# Check environment variables
echo $env:JAVA_HOME
echo $env:ANDROID_HOME

# Search for JDK installations
Get-ChildItem -Path "C:\" -Name "*jdk*" -Directory -ErrorAction SilentlyContinue
Get-ChildItem "C:\Program Files\Java\" -ErrorAction SilentlyContinue

# Search for Android installations  
Get-ChildItem -Path "C:\" -Name "*android*" -Directory -ErrorAction SilentlyContinue
Get-ChildItem "C:\Program Files\Android\" -ErrorAction SilentlyContinue
Enter fullscreen mode Exit fullscreen mode

Common Installation Locations

Android Studio JDK

C:\Program Files\Android\Android Studio\jbr\
Enter fullscreen mode Exit fullscreen mode

Android SDK (Default Location)

C:\Users\[Username]\AppData\Local\Android\Sdk
Enter fullscreen mode Exit fullscreen mode

Standard JDK Locations

C:\Program Files\Java\jdk-[version]\
C:\Program Files (x86)\Java\jdk-[version]\
Enter fullscreen mode Exit fullscreen mode

Setting Up Environment Variables

Temporary (Current Session Only)

$env:JAVA_HOME = "C:\Program Files\Android\Android Studio\jbr"
$env:ANDROID_HOME = "C:\Users\$env:USERNAME\AppData\Local\Android\Sdk"
Enter fullscreen mode Exit fullscreen mode

Permanent Configuration

[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Android\Android Studio\jbr", "User")
[Environment]::SetEnvironmentVariable("ANDROID_HOME", "C:\Users\$env:USERNAME\AppData\Local\Android\Sdk", "User")
Enter fullscreen mode Exit fullscreen mode

Verification Steps

# Verify Java installation
& "$env:JAVA_HOME\bin\java.exe" -version

# Verify Android SDK accessibility
Test-Path "$env:ANDROID_HOME\platform-tools\adb.exe"

# Check environment variables
echo "JAVA_HOME: $env:JAVA_HOME"
echo "ANDROID_HOME: $env:ANDROID_HOME"
Enter fullscreen mode Exit fullscreen mode

Part 3: Advanced Configuration

Custom npm Global Installation Directory

If you want to keep global npm packages on your D: drive:

# Set custom npm prefix
npm config set prefix "D:\npm-global"

# Update PATH temporarily
$env:PATH = "D:\npm-global;" + $env:PATH

# For permanent PATH update
[Environment]::SetEnvironmentVariable("Path", "D:\npm-global;" + [Environment]::GetEnvironmentVariable("Path", "User"), "User")
Enter fullscreen mode Exit fullscreen mode

Moving Existing Installations

For tools already installed on C: drive:

# Check current installation
Get-Command node
npm config get prefix

# Reinstall to new location
choco uninstall nodejs-lts -y
choco install -y nodejs-lts --params="'/InstallDir:D:\nodejs'"
Enter fullscreen mode Exit fullscreen mode

Part 4: Troubleshooting Common Issues

Chocolatey Installation Problems

Issue: Test-ProcessAdminRights not recognized
Solution: Run PowerShell as Administrator or reinstall Chocolatey

Issue: Directory does not exist errors

Solution: Create directories manually first:

mkdir D:\Chocolatey -Force
mkdir D:\Tools -Force
Enter fullscreen mode Exit fullscreen mode

Environment Variable Problems

Issue: Variables not persisting after reboot
Solution: Use [Environment]::SetEnvironmentVariable with "Machine" or "User" scope instead of temporary session variables

Issue: Tools not found after moving
Solution: Verify PATH includes new installation directories and restart terminal

Best Practices

  1. Always test installations after moving to new locations
  2. Keep backups of important projects before making system changes
  3. Document your configuration for future reference
  4. Use version control for configuration files
  5. Regularly update your development tools

Conclusion

Managing development tool installations on custom drives in Windows requires understanding of environment variables, package manager configurations, and system PATH settings. By following this guide, you can effectively organize your development environment across multiple drives, overcome storage limitations, and maintain an efficient workflow.

The key takeaways are:

  • Use Chocolatey environment variables for bulk tool management
  • Set JAVA_HOME and ANDROID_HOME for Android development
  • Configure npm prefix for Node.js package management
  • Always verify installations after configuration changes
  • Keep system and user environment variables organized

With these techniques, you can optimize your Windows development environment for better storage management and workflow efficiency.


This guide covers the complete journey from initial installation challenges to a fully configured development environment. Whether you're setting up a new machine or optimizing an existing one, these steps will help you maintain control over your development tool locations.

Top comments (0)