New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

copy-node

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-node

A simple Node.js library for clipboard operations across different platforms.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

copy-node

A simple Node.js library for clipboard operations across different platforms.

Features

  • Cross-platform clipboard support (macOS, Windows, Linux)
  • Easy-to-use Promise-based API
  • No external dependencies
  • TypeScript support with full type definitions
  • Supports both CommonJS and ES Modules

Installation

npm install copy-node

Usage

import { copy } from 'copy-node';

// Copy text to clipboard
await copy('Hello, World!');

// Copy variables or complex strings
const text = 'This text will be copied to clipboard';
await copy(text);

CommonJS

const { copy } = require('copy-node');

// Copy text to clipboard
copy('Hello, World!').then(() => {
  console.log('Text copied to clipboard');
}).catch((error) => {
  console.error('Failed to copy text:', error.message);
});

Platform Requirements

macOS

  • Built-in support via pbcopy

Windows

  • Built-in support via clip

Linux

  • Requires either xclip or xsel to be installed
  • The library will automatically try both tools as fallback

Installing clipboard utilities on Linux

Ubuntu/Debian:

# For xclip
sudo apt-get install xclip

# Or for xsel
sudo apt-get install xsel

CentOS/RHEL/Fedora:

# For xclip
sudo yum install xclip
# or on newer versions
sudo dnf install xclip

# Or for xsel
sudo yum install xsel
# or on newer versions
sudo dnf install xsel

API

copy(text: string): Promise<void>

Copies the provided text to the system clipboard.

Parameters:

  • text - The string to copy to clipboard

Returns:

  • A Promise that resolves when the copy operation completes successfully

Throws:

  • Error if the operation fails or platform is unsupported

Supported Platforms

  • macOS (darwin)
  • Windows (win32)
  • Linux (requires xclip or xsel)

Example

const { copy } = require('copy-node');

async function example() {
  try {
    await copy('Hello from copy-node!');
    console.log('Text copied to clipboard successfully!');
  } catch (error) {
    console.error('Failed to copy text:', error.message);
  }
}

example();

License

MIT

FAQs

Package last updated on 17 Sep 2025

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