Fork node-pty
pty tty terminal pseudoterminal forkpty openpty


Project Name ndb-node-pty-prebuilt Project Url https://github.com/ak239/ndb-node-pty#readme
InceptionYear 2018-07-24 01:40:37 更新时间 2018-07-24 14:36:01
IssueManagement https://github.com/ak239/ndb-node-pty/issues Licenses MIT
仓库地址 git+https://github.com/ak239/ndb-node-pty.git 用户数 0
Node Engine >=8.0.0 文件大小 2.4 MB
install tsc lint install postinstall test prepublish



Note: this repository is node-pty fork with two changes: - prebuilt binaries for Node 8, Node 9 and Node 10 are shipped as part of package, - install script first try to lookup prebuilt binary before building.

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:

  • Writing a terminal emulator (eg. via xterm.js).
  • Getting certain programs to think you're a terminal, such as when you need a program to send you control sequences.

node-pty supports Linux, macOS and Windows. Windows support is possible by utilizing the winpty library.

Real-world Uses

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.

Example Usage

```js var os = require('os'); var pty = require('node-pty');

var shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';

var ptyProcess = pty.spawn(shell, [], { name: 'xterm-color', cols: 80, rows: 30, cwd: process.env.HOME, env: process.env });

ptyProcess.on('data', function(data) { console.log(data); });

ptyProcess.write('ls\r'); ptyProcess.resize(100, 40); ptyProcess.write('ls\r');



bash # Install dependencies and build C++ npm install # Compile TypeScript -> JavaScript npm run tsc

Dependencies on Windows

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:

sh npm install --global --production windows-build-tools


On Windows, you can show the winpty agent console window by adding the environment variable WINPTY_SHOW_CONSOLE=1 to the pty's environment. See https://github.com/rprichard/winpty#debugging-winpty for more information.


Powershell gives error 8009001d

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 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).


GroupId ArtifactID Version 引用量
Kevin Mårtensson decompress 4.2.1 566
Kevin Mårtensson decompress-targz 4.1.1 29
kkoopa nan 2.14.1 4104


GroupId ArtifactID Version 引用量
Kent C. Dodds cross-env 7.0.2 44045
Sokratis Vidros pollUntil 1.0.3 9
palantir tslint 6.1.3 67922
ajaff tslint-consistent-codestyle 1.16.0 414