Skip to content

Latest commit

 

History

History
114 lines (80 loc) · 3.1 KB

File metadata and controls

114 lines (80 loc) · 3.1 KB

@karinjs/node-pty

A lightweight prebuilt node-pty package, optimized based on @homebridge/node-pty-prebuilt-multiarch.

English | 简体中文

Features

  • 🚀 Ultra-lightweight: Removed source code, keeping only necessary prebuilt binaries
  • 🇨🇳 China-friendly: Uses npmmirror.com mirror by default
  • 💪 Multi-arch support: Supports major operating systems and CPU architectures
  • 🔧 Ready to use: No compilation needed, supports multiple package managers

Warning

Currently only tested in Windows Node.js environment. Compatibility with other environments (Linux, macOS, etc.) needs to be verified by users. Feedback is welcome if you encounter any issues.

Installation

Using npm:

npm install @karinjs/node-pty

Using yarn:

yarn add @karinjs/node-pty

Using pnpm:

pnpm add @karinjs/node-pty

Using aliases:

npm install node-ptym:@karinjs/node-pty
# or
npm install @homebridge/node-pty-prebuilt-multiarch:@karinjs/node-pty

Supported Environments

OS Architectures
macOS x64, arm64
Linux (glibc) ia32, x64, armv6, aarch64
Linux (musl) x64, armv6, aarch64
Windows ia32, x64

Note: Only supports Node.js 16+ and Electron 16.0.0+ (excluding Electron 28)

Notes

Since this package is distributed in prebuilt form, installation depends on network stability. If you encounter download issues, you can:

  1. Use a proxy
  2. Switch to another package manager
  3. Retry installation multiple times

Version Mapping

@karinjs/node-pty @homebridge/node-pty-prebuilt-multiarch
1.0.2 0.11.14

Upstream Projects

This project is based on these excellent open source projects:

License

This project is open-sourced under the MIT License. Thanks to the contributions from:

  • Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
  • Copyright (c) 2016, Daniel Imms (MIT License)
  • Copyright (c) 2018, Microsoft Corporation (MIT License)
  • Copyright (c) 2018, David Wilson (MIT License)
  • Copyright (c) 2018, oznu (MIT License)
  • Copyright (c) 2023, Homebridge (MIT License)

Usage Example

import * as os from "node:os";
import * as pty from "@karinjs/node-pty";

async function run() {
  const shell = os.platform() === "win32" ? "powershell.exe" : "bash";
  const ptyProcess = pty.spawn(shell, [], {
    name: "xterm-color",
    cols: 80,
    rows: 30,
    cwd: process.env.HOME,
    env: process.env,
  });

  ptyProcess.onData((data) => {
    process.stdout.write(data);
  });

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

run();