dependency-time-machine: An Easier Way to Update NPM packages
Automatically update your package.json dependencies one by one in chronological order, ensuring compatibility and reducing errors
Updating Node dependencies is a headache. Things often break, or dependencies conflict because they’ve been updated at different times. It’s frustrating when you run into issues after an update, especially when you don’t know which package caused the problem.
Managing dependencies manually is time-consuming, and figuring out the right order to update them in is tricky. One outdated dependency can throw off your entire project, and fixing it can feel like you’re playing whack-a-mole with bugs.
I came across a handy package called dependency-time-machine(thanks pilotpirxie). It streamlines the process by updating your dependencies one at a time in the order they were released, making sure everything remains compatible and works together seamlessly.
How dependency-time-machine works:
Reads your package.json
Finds the release dates for each dependency.
Updates them one by one, in the order they were released.
Runs your tests after each update to check for compatibility issues.
Usage
Run dependency-time-machine with npx to find the next recommended dependency to update.
dependency-time-machine finds that hapi has a new version (17.5.0) released on May 21, 2018. It updates hapi in the package.json, installs the new version, and issues a warning that this version has known security defects and should be updated to a more secure version.
Skipping Major Versions
Use the --stop-if-higher-major-number flag to skip over major versions. This will prevent the tool from updating to the next major version and instead keep it within the current major version range, ensuring more stable updates. Here’s an example:
In this case, we updated to [email protected], staying within the same major version (5.x.x), skipping any updates that would have moved to a higher major version (like 6.x.x or higher). This helps keep updates stable and avoids breaking changes from major version bumps.
Excluding Dependencies
To skip certain dependencies from being updated, use the -e flag:
Hapi was excluded from the update process:
What about private registries? Not a problem.
Use the -r flag to specify your own private registry URL. Replace the example URL with your own.
Here are engineering resources I've personally vetted and use. They focus on skills you'll actually need to build and scale real projects - the kind of experience that gets you hired or promoted.
Many companies have a fixed annual stipend per engineer (e.g. $2,000) for use towards learning resources. If your company offers this stipend, you can forward them your invoices directly for reimbursement.