Skip to content

Resolving 'process.env' TypeError During windows-build-tools Installation

Problem Statement

When running npm install --global windows-build-tools on Node.js v18.12.0 (or newer), you encounter this fatal error:

TypeError: 'process.env' only accepts a configurable, writable, and enumerable data descriptor.

This occurs because the windows-build-tools package has compatibility issues with newer Node.js versions (v18+). The installer fails during environment validation, preventing installation of required build tools like Visual Studio Build Tools or Python.

Optimal Solution: Install Build Tools via Official Installer

RECOMMENDED

The current preferred approach avoids windows-build-tools entirely

  1. Uninstall your current Node.js version
  2. Download the Official Node.js Windows Installer for your desired version
  3. During installation:
    • Check the box for "Tools for Native Modules"
      (Enables automatic installation of C++ build tools)
      Tools for Native Modules option in installer
  4. After Node.js installation completes:
    • A new PowerShell window will automatically install necessary build tools
  5. Verify installation by compiling native modules or installing packages that require compilation

Alternative Method: Manual VS Build Tools Installation

If you prefer manual control:

  1. Download Visual Studio Build Tools
  2. In the installer:
    • Select "Desktop development with C++" workload
    • Include all default components
  3. Run in administrative terminal after installation:
    powershell
    npm config set msvs_version 2022
  4. Test native module compilation

Compatibility Workaround: Downgrade Node.js

LEGACY APPROACH

Only use if you cannot use the recommended methods

  1. Uninstall Node.js v18+
  2. Install Node.js v17.9.1
  3. Open temporary directory:
    • Press Win + R, type %temp%, press Enter
  4. Create file dd_client_.log.txt with content:
    txt
    Closing installer. Return code: 3010.
  5. Run in administrative terminal:
    bash
    npm install --global windows-build-tools
  6. After successful installation, carefully upgrade Node.js if needed

Key Technical Insights

Why This Happens

The windows-build-tools package uses an outdate approach to configure process.env properties that conflicts with newer security restrictions in Node.js v18+.

Modern Alternatives

The Node.js installer now integrates with Microsoft's build tools chain, providing:

  • Automatic installation of required components
  • Better version management
  • First-party support from Microsoft

Maintenance Status

Windows-build-tools has had no significant updates since 2020 and should be avoided for new setups.

Verification Steps

After successful setup:

  1. Install a native module package:
    bash
    npm install bcrypt
  2. Verify compilation:
    bash
    node -e "require('bcrypt')"
    (No errors = successful setup)

Maintenance Note

For long-term projects, use the integrated toolchain method to ensure compatibility with future Node.js releases.

Summary of Approaches

MethodWhen to UseMaintenance Level
Official Node.js Installer✅ New setups, most reliable approachFirst-party
Manual VS Build Tools InstallWhen you need control over VS componentsSupported
Node v17 + Temp File Workaround🛑 Only for legacy applicationsUnmaintained