{"id":13422011,"url":"https://github.com/sindresorhus/trash","last_synced_at":"2026-01-25T13:04:01.813Z","repository":{"id":17024970,"uuid":"19789032","full_name":"sindresorhus/trash","owner":"sindresorhus","description":"Move files and directories to the trash","archived":false,"fork":false,"pushed_at":"2024-07-26T12:21:13.000Z","size":689,"stargazers_count":2585,"open_issues_count":13,"forks_count":80,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-05-03T00:26:34.237Z","etag":null,"topics":["delete","nodejs","npm-package","recycle-bin","trash"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-05-14T17:25:32.000Z","updated_at":"2025-04-27T00:13:02.000Z","dependencies_parsed_at":"2024-11-05T18:35:30.702Z","dependency_job_id":"15ba80b4-6b26-4dea-ba9c-2e1454fc56c1","html_url":"https://github.com/sindresorhus/trash","commit_stats":{"total_commits":152,"total_committers":26,"mean_commits":5.846153846153846,"dds":0.2171052631578947,"last_synced_commit":"52b23c24721c91e155806767cd3d260e7f9db97b"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ftrash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ftrash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ftrash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ftrash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/trash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252308761,"owners_count":21727257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["delete","nodejs","npm-package","recycle-bin","trash"],"created_at":"2024-07-30T23:00:35.541Z","updated_at":"2026-01-25T13:04:01.809Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# ![trash](media/logo.png)\n\n\u003e Move files and folders to the trash\n\nWorks on macOS (10.12+), Linux, and Windows (8+).\n\n**Note:** The Linux implementation is not very good and not maintained. Help welcome. If no one steps up to help maintain it, I will eventually remove Linux support.\n\nIn contrast to [`fs.unlink`](https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback), [`del`](https://github.com/sindresorhus/del), and [`rimraf`](https://github.com/isaacs/rimraf) which permanently delete files, this only moves them to the trash, which is much safer and reversible.\n\n## Install\n\n```sh\nnpm install trash\n```\n\n## Usage\n\n```js\nimport trash from 'trash';\n\nawait trash(['*.png', '!rainbow.png']);\n```\n\n## API\n\n### trash(input, options?)\n\nReturns a `Promise`.\n\n#### input\n\nType: `string | string[]`\n\nAccepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).\n\nNon-existent files and glob patterns that match nothing are silently ignored. If you need to know whether files were actually trashed, check for their existence beforehand.\n\n#### options\n\nType: `object`\n\n##### glob\n\nType: `boolean`\\\nDefault: `true`\n\nEnable globbing when matching file paths.\n\n## CLI\n\nTo install the [`trash`](https://github.com/sindresorhus/trash-cli) command, run:\n\n```sh\nnpm install --global trash-cli\n```\n\n## Info\n\nOn macOS, [`macos-trash`](https://github.com/sindresorhus/macos-trash) is used.\\\nOn Linux, the [XDG spec](https://specifications.freedesktop.org/trash/1.0/) is followed.\\\nOn Windows, [`recycle-bin`](https://github.com/sindresorhus/recycle-bin) is used.\nOn WSL (Windows Subsystem for Linux), files are moved to the Windows Recycle Bin.\n\n## FAQ\n\n### But I can do the same thing with `mv`\n\nNot really. The `mv` command isn't cross-platform and moving to trash is not just about moving the file to a \"trash\" directory. On all OSes you'll run into file conflicts. The user won't easily be able to restore the file. It won't work on an external drive. The trash directory location varies between Windows versions. For Linux, there's a whole [spec](https://standards.freedesktop.org/trash-spec/trashspec-1.0.html) you need to follow. On macOS, you'll lose the [Put back](https://mac-fusion.com/trash-tip-how-to-put-files-back-to-their-original-location/) feature.\n\n### Windows service account behavior\n\nWhen running as the Windows SYSTEM account or other service accounts, files are moved to that account's recycle bin (e.g., `C:\\$Recycle.Bin\\S-1-5-18\\` for SYSTEM). These files won't be visible in the normal user's recycle bin and may accumulate over time. For service contexts, consider using direct file deletion instead.\n\n## Related\n\n- [trash-cli](https://github.com/sindresorhus/trash-cli) - CLI for this module\n- [empty-trash](https://github.com/sindresorhus/empty-trash) - Empty the trash\n- [del](https://github.com/sindresorhus/del) - Delete files and folders\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","JavaScript","包","Web 后端","目录","Tools","Command-line apps","Uncategorized","Developer Tools","开发者工具"],"sub_categories":["Command-line apps","命令行程序","命令行应用","Node","Uncategorized","Command Line Tools","命令行工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ftrash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Ftrash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ftrash/lists"}