Socket
Socket
Sign inDemoInstall

node-pty

Package Overview
Dependencies
Maintainers
1
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pty

Pseudo terminals for node


Version published
Weekly downloads
107K
decreased by-13.83%
Maintainers
1
Weekly downloads
 
Created

What is node-pty?

The node-pty package is a Node.js library that provides bindings to pseudo terminals (PTYs). It allows you to spawn and interact with terminal processes programmatically, making it useful for building terminal emulators, remote shells, and other command-line interface (CLI) tools.

What are node-pty's main functionalities?

Spawning a Terminal Process

This feature allows you to spawn a terminal process. The code sample demonstrates how to spawn a shell process and listen for data events to capture the terminal output.

const pty = require('node-pty');
const shell = process.env[process.platform === 'win32' ? 'COMSPEC' : 'SHELL'];
const ptyProcess = pty.spawn(shell, [], {
  name: 'xterm-color',
  cols: 80,
  rows: 30,
  cwd: process.cwd(),
  env: process.env
});
ptyProcess.on('data', function(data) {
  console.log(data);
});

Resizing the Terminal

This feature allows you to resize the terminal window. The code sample shows how to resize the terminal to 100 columns and 40 rows.

ptyProcess.resize(100, 40);

Writing to the Terminal

This feature allows you to send input to the terminal process. The code sample demonstrates how to send the 'ls' command to the terminal.

ptyProcess.write('ls\r');

Other packages similar to node-pty

Keywords

FAQs

Package last updated on 16 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc