Updating Node.js Dependencies with dependency-time-machine

November, 14th 2024 2 min read

Updating Node.js Dependencies with dependency-time-machine

Updating dependencies is critical for security, performance, and compatibility — but doing it manually can break your project. The dependency-time-machine tool solves this by updating packages one at a time in chronological order, letting you detect breaking changes early and keep your project stable.

This guide walks you through installation, automatic updates, test automation, exclusions, and advanced usage.

1. Install dependency-time-machine

You can run the tool without installing anything using npx:

plaintext
npx dependency-time-machine --update --install

Or install it globally:

plaintext
npm install -g dependency-time-machine

Once installed, the CLI becomes available as dependency-time-machine.

2. Run an Update Cycle

To begin updating dependencies safely, run:

plaintext
npx dependency-time-machine --update --install

What this does:

  • scans your package.json
  • detects outdated dependencies
  • updates them sequentially, not all at once
  • installs after each bump
  • stops if a new version breaks your project

This step-by-step approach is much safer than npm update or npm-check-updates.

3. Automate Tests During Updates

Enable auto-testing:

plaintext
npx dependency-time-machine --update --install --auto

By default, it runs:

plaintext
npm test

You can customize both install and test commands:

plaintext
npx dependency-time-machine   --update --install --auto   --install-script "yarn install"   --test-script "yarn test"

4. Exclude Specific Dependencies

plaintext
npx dependency-time-machine --update --install --exclude react,react-dom

5. Advanced Usage

Exclude via file

Create a file:

plaintext
react
typescript
webpack

Then:

plaintext
npx dependency-time-machine --update --install --exclude-file skip.txt

Generate timeline

plaintext
npx dependency-time-machine --timeline

Dry run

plaintext
npx dependency-time-machine --update --dry

6. Combine with Other Tools

Fast bulk updating:
Update NPM Dependencies

Conclusion

dependency-time-machine provides one of the safest ways to modernize dependencies. With sequential updates, automated tests, and advanced controls, it helps maintain stability in every Node.js project.