Gathering detailed insights and metrics for node-pty
Gathering detailed insights and metrics for node-pty
Gathering detailed insights and metrics for node-pty
Gathering detailed insights and metrics for node-pty
npm install node-pty
Typescript
Module System
Node Version
NPM Version
TypeScript (51.34%)
C++ (38.93%)
JavaScript (6.64%)
Python (1.89%)
C (1.21%)
Total Downloads
63,582,483
Last Day
63,710
Last Week
336,384
Last Month
898,688
Last Year
7,999,761
NOASSERTION License
1,632 Stars
1,194 Commits
273 Forks
33 Watchers
23 Branches
131 Contributors
Updated on Aug 29, 2025
Latest Version
1.0.0
Package Id
node-pty@1.0.0
Unpacked Size
1.09 MB
Size
244.74 kB
File Count
251
NPM Version
8.19.4
Node Version
16.20.0
Published on
Jun 12, 2023
Cumulative downloads
Total Downloads
Last Day
73.1%
63,710
Compared to previous day
Last Week
79.6%
336,384
Compared to previous week
Last Month
39.2%
898,688
Compared to previous month
Last Year
49.8%
7,999,761
Compared to previous year
1
forkpty(3)
bindings for node.js. This allows you to fork processes with pseudoterminal file descriptors. It returns a terminal object which allows reads and writes.
This is useful for:
node-pty
supports Linux, macOS and Windows. Windows support is possible by utilizing the Windows conpty API on Windows 1809+ and the winpty library in older version.
The full API for node-pty is contained within the TypeScript declaration file, use the branch/tag picker in GitHub (w
) to navigate to the correct version of the API.
1var os = require('os'); 2var pty = require('node-pty'); 3 4var shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash'; 5 6var ptyProcess = pty.spawn(shell, [], { 7 name: 'xterm-color', 8 cols: 80, 9 rows: 30, 10 cwd: process.env.HOME, 11 env: process.env 12}); 13 14ptyProcess.onData((data) => { 15 process.stdout.write(data); 16}); 17 18ptyProcess.write('ls\r'); 19ptyProcess.resize(100, 40); 20ptyProcess.write('ls\r');
node-pty
powers many different terminal emulators, including:
Do you use node-pty in your application as well? Please open a Pull Request to include it here. We would love to have it in our list.
1# Install dependencies and build C++ 2npm install 3# Compile TypeScript -> JavaScript 4npm run build
Node.JS 16 or Electron 19 is required to use node-pty
. What version of node is supported is currently mostly bound to whatever version Visual Studio Code is using.
1sudo apt install -y make python build-essential
Xcode is needed to compile the sources, this can be installed from the App Store.
npm install
requires some tools to be present in the system like Python and C++ compiler. Windows users can easily install them by running the following command in PowerShell as administrator. For more information see https://github.com/felixrieseberg/windows-build-tools:
1npm install --global --production windows-build-tools
The following are also needed:
The wiki contains instructions for debugging node-pty.
All processes launched from node-pty will launch at the same permission level of the parent process. Take care particularly when using node-pty inside a server that's accessible on the internet. We recommend launching the pty inside a container to protect your host machine.
Note that node-pty is not thread safe so running it across multiple worker threads in node.js could cause issues.
Automatic flow control can be enabled by either providing handleFlowControl = true
in the constructor options or setting it later on:
1const PAUSE = '\x13'; // XOFF 2const RESUME = '\x11'; // XON 3 4const ptyProcess = pty.spawn(shell, [], {handleFlowControl: true}); 5 6// flow control in action 7ptyProcess.write(PAUSE); // pty will block and pause the child program 8... 9ptyProcess.write(RESUME); // pty will enter flow mode and resume the child program 10 11// temporarily disable/re-enable flow control 12ptyProcess.handleFlowControl = false; 13... 14ptyProcess.handleFlowControl = true;
By default PAUSE
and RESUME
are XON/XOFF control codes (as shown above). To avoid conflicts in environments that use these control codes for different purposes the messages can be customized as flowControlPause: string
and flowControlResume: string
in the constructor options. PAUSE
and RESUME
are not passed to the underlying pseudoterminal if flow control is enabled.
Internal Windows PowerShell error. Loading managed Windows PowerShell failed with error 8009001d.
This happens when PowerShell is launched with no SystemRoot
environment variable present.
This error can occur due to anti-virus software intercepting winpty from creating a pty. To workaround this you can exclude this file from your anti-virus scanning node-pty\build\Release\winpty-agent.exe
This project is forked from chjj/pty.js with the primary goals being to provide better support for later Node.JS versions and Windows.
Copyright (c) 2012-2015, Christopher Jeffrey (MIT License).
Copyright (c) 2016, Daniel Imms (MIT License).
Copyright (c) 2018, Microsoft Corporation (MIT License).
No vulnerabilities found.
node-pty-prebuilt-multiarch
Fork pseudoterminals in Node.JS
@homebridge/node-pty-prebuilt-multiarch
Fork pseudoterminals in Node.JS
@faressoft/node-pty-prebuilt
A parallel fork of node-pty providing prebuilt packages for Node.js and Electron
node-pty-prebuilt-multiarch-cp
Fork pseudoterminals in Node.JS