[RRFC] Exclude `node_modules` from Time Machine backups (macOS)

Open
#471 11 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
tooling

Research direction

Start by reviewing the RFC's desired behavior and its referenced Cargo and Poetry implementations, then identify the npm code path that creates or manages node_modules folders. Done means node_modules folders receive the specified macOS backup-exclusion xattr and the behavior is verified on macOS.

Written by the indexing model from the issue text.

Description

Motivation

node_modules often contains a lot of files that change frequently, which can significantly slow down backup solutions like Time Machine, so it would make sense to exclude them from backups.

How

Current Behaviour

node_modules folders are included in Time Machine backups

Desired Behaviour

Exclude node_modules from Time Machine backups using a "sticky exclusion". This can be done by adding the xattr com.apple.metadata:com_apple_backup_excludeItem to the node_modules folders with the value com.apple.backupd encoded as a binary plist:

00000000  62 70 6C 69 73 74 30 30 5F 10 11 63 6F 6D 2E 61  |bplist00_..com.a|
00000010  70 70 6C 65 2E 62 61 63 6B 75 70 64 08 00 00 00  |pple.backupd....|
00000020  00 00 00 01 01 00 00 00 00 00 00 00 01 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00 00 00 00 00 1C           |.............|
0000003d

References

Rust already does this for their target folders: https://github.com/rust-lang/cargo/pull/4386
My PR for implementing this for the poetry Python package manager: https://github.com/python-poetry/poetry/pull/4599

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from npm/rfcs

All issues in npm/rfcs

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.