The `cp` package is a lightweight Node.js utility designed for straightforward file copying, offering both asynchronous callback-based and synchronous APIs. Its current stable version is 0.2.0, with the last notable activity and publication on npm dating back to November 2014. Due to its age and lack of maintenance over many years, this package is considered abandoned. It was initially differentiated by its simplicity and direct approach to file operations, contrasting with more feature-rich but potentially complex alternatives or the direct use of Node.js's native `fs` module. The asynchronous API primarily uses callbacks, although the README mentions `yield cp(src, dest)`, indicating a pattern likely intended for use with generator-based flow control libraries (like `co`) that were common before native `async/await` became widespread. The package does not natively support modern promise-based or `async/await` patterns, which are now standard in Node.js.
npm install cpVerified import paths — ran on the pinned version, not inferred.
Demonstrates both synchronous and asynchronous file copying using `cp` and `cp.sync` with cleanup.
Migrate to a actively maintained and more robust file system utility like `fs.promises.copyFile` (native to Node.js since v8.5.0), `fs-extra` (for broader utility), or `cp-file`.
If migrating is not immediately possible, use Node.js's `util.promisify` to convert the callback-based API to a Promise-based one for use with `async/await`, but prioritize migration to a modern library.
For advanced copying needs (recursive, preserving permissions, error handling), use `fs-extra`'s `copy` function, or Node.js's native `fs.cp` (since v16.7.0) / `fs.cpSync` (since v16.7.0) which supports recursive copying and more options.
Ensure you are using `const cp = require('cp');` for CommonJS environments, as the package does not support ESM `import` statements.Verify that the `src` path points to an existing file before calling `cp` or `cp.sync`. Implement path validation or `fs.existsSync` checks.
Ensure the Node.js process has the necessary file system permissions to read the source and write to the destination. On Linux/macOS, consider `sudo` for scripts or checking directory ownership and permissions (e.g., `chmod`).
No dependency data recorded yet.