Skip to content

node-pty fails to build on Windows with VS2022 (v143 toolset): conpty.cc uses undeclared identifiers and goto error #2

Description

@x0x0x8x

Environment
OS: Windows 11

Node.js: v22.23.2

npm: (whatever version)

Visual Studio: VS2022 Community 17.14.38 (v143 toolset)

Windows SDK: 10.0.26100.0

node-pty version: 1.0.0

Steps to reproduce
Clone interactive-shell-mcp repository

Run npm install

Run npm rebuild node-pty

Build fails

Error logs
text
conpty.cc(127,5): error C2065: “PFNCREATEPSEUDOCONSOLE”: 未声明的标识符
conpty.cc(127,28): error C2143: 语法错误: 缺少“;”(在“const”的前面)
conpty.cc(127,28): error C4430: 缺少类型说明符 - 假定为 int
...
winpty.cc(218,25): error C2362: “goto cleanup”跳过了“marshal”的初始化
winpty.cc(209,8): error C2362: “goto cleanup”跳过了“spawnSuccess”的初始化
winpty.cc(208,10): error C2362: “goto cleanup”跳过了“handle”的初始化
winpty.cc(200,26): error C2362: “goto cleanup”跳过了“config”的初始化
Full log: [paste your log]

Analysis
The build fails because:

PFNCREATEPSEUDOCONSOLE and related ConPTY API types are not defined. This is likely due to the code not properly defining _WIN32_WINNT to the required version (needs 0x0A00 or higher for ConPTY)

The winpty.cc file contains goto cleanup statements that jump over variable initializations, which is disallowed in C++

Attempted fixes
Installed Visual Studio Build Tools 2022 with "Desktop development with C++" workload

Installed Spectre-mitigated libraries

Ran npm rebuild from VS2022 Developer Command Prompt

Tried Node.js v22 and v26

Same error in all cases

Suggested fix
Add #define _WIN32_WINNT 0x0A00 before including Windows headers

Or update the binding.gyp to define the required Windows version

Fix the goto-initialization issues in winpty.cc

Feature Request / Suggestion
I've been trying to get this MCP server working on Windows for several hours, and the node-pty build process has been the main blocker. The compilation fails due to ConPTY API definitions and goto initialization errors.

For Windows users who are not familiar with C++ build toolchains, this is a frustrating experience. I would like to suggest:

Provide a pre-built release or a dependency installation script

Pre-built binaries: Ship a pre-built node-pty binary for Windows in the release artifacts. Users could then install with npm install --ignore-scripts and use the pre-built version.

Dependency checklist / installation script: Provide a PowerShell script that automatically checks and installs the required Visual Studio components via vswhere and VSIXInstaller. This would eliminate the guesswork.

Recommend the official MCP server for Windows users: If there is already a known working alternative that doesn't require compiling node-pty, please document it.

This would greatly improve the experience for Windows developers who just want to use the tool without spending hours on environment setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions