Skip to content

Instantly share code, notes, and snippets.

@Suvink
Created December 1, 2025 04:30
Show Gist options
  • Select an option

  • Save Suvink/69586e3ad7ae789c43ef2ccebe29cef6 to your computer and use it in GitHub Desktop.

Select an option

Save Suvink/69586e3ad7ae789c43ef2ccebe29cef6 to your computer and use it in GitHub Desktop.
Check Release Dates of Your Dependancies

NPM Package Version Date Checker

A simple Node.js script to check when your package dependencies were published to npm registry.

Purpose

This tool helps you verify if the versions of packages in your package.json were released before a specific date (November 20, 2025 by default).

Requirements

  • Node.js (no additional dependencies required - uses built-in modules)

Installation

  1. Save check-versions.js to your project directory
  2. That's it! No npm install needed.

Usage

# Check package.json in current directory
node check-versions.js

# Check a specific package.json file
node check-versions.js path/to/package.json

Output

The script displays a formatted table with:

  • Package name
  • Version specified in package.json
  • Publication date from npm registry
  • Whether it was published before November 20, 2025

Example output:

Package Name                            Version        Published      Before Nov 20, 2025
------------------------------------------------------------------------------------------
base64url                               3.0.1          2018-04-23     Yes
cookie                                  0.4.2          2021-02-15     Yes
express                                 4.21.2         2024-10-08     Yes

How It Works

The script:

  1. Reads your package.json file
  2. Extracts all dependencies and devDependencies
  3. Queries the npm registry API for each package
  4. Retrieves the exact publication date for each version
  5. Compares against the cutoff date

Note

The script includes a 100ms delay between API requests to avoid rate limiting from the npm registry.

const fs = require("fs");
const https = require("https");
// Function to fetch package info from npm registry API
function fetchPackageInfo(packageName, version) {
return new Promise((resolve, reject) => {
const url = `https://registry.npmjs.org/${packageName}`;
https
.get(url, (res) => {
let data = "";
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
try {
const json = JSON.parse(data);
// Clean version string (remove ^, ~, etc.)
const cleanVersion = version.replace(/[\^~>=<]/g, "");
if (json.time && json.time[cleanVersion]) {
const publishDate = new Date(json.time[cleanVersion]);
const cutoffDate = new Date("2025-11-20");
const isBeforeCutoff = publishDate < cutoffDate;
resolve({
package: packageName,
version: cleanVersion,
publishDate: publishDate.toISOString().split("T")[0],
beforeNov20: isBeforeCutoff ? "Yes" : "No",
});
} else {
resolve({
package: packageName,
version: cleanVersion,
publishDate: "Not found",
beforeNov20: "Unknown",
});
}
} catch (e) {
reject(e);
}
});
})
.on("error", (err) => {
reject(err);
});
});
}
// Main function
async function checkPackageVersions(packageJsonPath) {
try {
// Read package.json
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
// Combine dependencies and devDependencies
const allDeps = {
...packageJson.dependencies,
...packageJson.devDependencies,
};
console.log("Checking package versions...\n");
console.log("Package Name".padEnd(40) + "Version".padEnd(15) + "Published".padEnd(15) + "Before Nov 20, 2025");
console.log("-".repeat(90));
// Process packages one by one to avoid rate limiting
for (const [packageName, version] of Object.entries(allDeps)) {
try {
const info = await fetchPackageInfo(packageName, version);
console.log(
info.package.padEnd(40) + info.version.padEnd(15) + info.publishDate.padEnd(15) + info.beforeNov20
);
// Small delay to avoid rate limiting
await new Promise((resolve) => setTimeout(resolve, 100));
} catch (err) {
console.log(packageName.padEnd(40) + version.padEnd(15) + "Error".padEnd(15) + "Unknown");
}
}
} catch (err) {
console.error("Error reading package.json:", err.message);
}
}
// Run the script
const packageJsonPath = process.argv[2] || "./package.json";
checkPackageVersions(packageJsonPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment